I am trying to scrape a table from url. The table seems to have no name. I have scraped the links and its text to csv using below code.
from bs4 import BeautifulSoup
import requests
import re
url = 'https://www.sbp.org.pk/smefd/circulars/2020/index.htm'
r = requests.get(url)
soup = BeautifulSoup(r.content, 'html.parser')
anchor = soup.find_all('a',href = re.compile('2020'))
file_name = "Circulars.csv"
f = open(file_name,'w')
header = 'Cir_Name ,Links\n'
f.write(header)
for link in anchor:
href = link.get('href')
text = link.getText()
text1 = text.replace("\n", "")
f.write(text1.replace(',','|') + "," + href.replace("," ,"|") +"\n")
print("Done")
What I need is to scrape the table as it is. currently I am able to get just links. I need other columns too.
I have tried following code but failed. I am able to get to the table but thats not enough
from bs4 import BeautifulSoup
import requests
import re
url = 'https://www.sbp.org.pk/smefd/circulars/2020/index.htm'
r = requests.get(url)
soup = BeautifulSoup(r.content, 'html.parser')
table = soup.find_all('table',attrs={"width": "95%",'border':'0','cellpadding':"1"})
tablee = soup.find_all('tr',attrs={'table',attrs={"width": "95%",'border':'0','cellpadding':"1"}})
print(tablee)
