Home > OS >  When I print the dataframe it does not print the entire url. Ex: "https://url/abc..... so when
When I print the dataframe it does not print the entire url. Ex: "https://url/abc..... so when

Time:07-29

import pandas as pd
import bs4
from urllib.parse import urljoin
import requests
ibca_url = "https://ibcabbq.org/events/"
ibca_resp = requests.get(ibca_url)
page_soup = bs4.BeautifulSoup(ibca_resp.text, features="lxml")


# IBCA Event Details
ibca_event_details_links = []
for li in page_soup.find_all('li'):
    if "homepage_contest_list" in li["class"]:
        ibca_event_details_links.append(urljoin(ibca_url, li.a['href']))

df_ibca_event_details_links = pd.DataFrame(ibca_event_details_links)
print(df_ibca_event_details_links)

When I print the dataframe it does not print the entire url. Ex: "https://url/abc..... so when i copy and paste the webpage isnt found

CodePudding user response:

Use to_string to force a full display with print:

print(df_ibca_event_details_links.to_string())

output:

                                                      0
0  https://ibcabbq.org/contest-details/?contestid=10140
1  https://ibcabbq.org/contest-details/?contestid=10074
2   https://ibcabbq.org/contest-details/?contestid=9695
3  https://ibcabbq.org/contest-details/?contestid=10086
4   https://ibcabbq.org/contest-details/?contestid=9726
5   https://ibcabbq.org/contest-details/?contestid=9782
6   https://ibcabbq.org/contest-details/?contestid=9761
7   https://ibcabbq.org/contest-details/?contestid=9722
8   https://ibcabbq.org/contest-details/?contestid=9740

CodePudding user response:

Your code seems to work fine.
Try df_ibca_event_details_links.to_dict() to show the full URL's.

Output:

{0: {0: 'https://ibcabbq.org/contest-details/?contestid=10140',
  1: 'https://ibcabbq.org/contest-details/?contestid=10074',
  2: 'https://ibcabbq.org/contest-details/?contestid=9695',
  3: 'https://ibcabbq.org/contest-details/?contestid=10086',
  4: 'https://ibcabbq.org/contest-details/?contestid=9726',
  5: 'https://ibcabbq.org/contest-details/?contestid=9782',
  6: 'https://ibcabbq.org/contest-details/?contestid=9761',
  7: 'https://ibcabbq.org/contest-details/?contestid=9722',
  8: 'https://ibcabbq.org/contest-details/?contestid=9740'}}
  • Related