I am trying to extract some information from a table which appears on a webpage. I am able to extract all the data as wanted but get stuck at scraping the pdf links inside.
This is my source code:
Here is my code working so far:
import pandas as pd
import requests
from bs4 import BeautifulSoup
hdr={'User-Agent':'Chrome/84.0.4147.135'}
dfs=[]
for page_number in range(0,10):
http= "https://example.com/portal/ap_list_all.php?sPage={}".format(page_number)
print('Downloading page %s...' % http)
url= requests.get(http,headers=hdr)
soup = BeautifulSoup(url.text, 'html.parser')
table = soup.find('table')
df_list= pd.read_html(url.text)
df = pd.concat(df_list)
df['Link'] = [link.get('href') for link in table.find_all('a')]
dfs.append(df)
final_df = pd.concat(dfs)
final_df.to_csv('myscraper.csv',index=False,encoding='utf-8-sig')
The result I want is as below, coupled with the additional column of pdf links:
Any help would be appreciated. Thank you so much in advance.


