url = ('https://cameradecision.com/compare/Fujifilm-X-T30-vs-Sony-Alpha-a6400')
source = requests.get (url)
soup = BeautifulSoup(source.text,'html.parser')
rows = soup.find('table', {'class':'table table-striped table-condensed tableCompare'}).find('tbody').find_all('tr')
myfeatures = []
vs1 = []
vs2 = []
myresult = []
for row in rows:
dic = {}
dic['myfeatures'] = row.find_all('td')[0].text.replace("\n" , "" )
dic['vs1'] = row.find_all('td')[1].find('span', class_="read1").text
dic['vs2'] = row.find_all('td')[1].find('span', class_="read2").text
dic['myresult'] = row.find_all('td')[2].text.replace("\n" , "" )
myfeatures.append(dic)
print(myfeatures)
df = pd.DataFrame (myfeatures)
df.to_csv ( '/Users/jitendersingh/Documents/myfeatures.csv', mode = 'a' , index = False , header = False )
print ( "my table file created successfully." )
0 comments:
Post a Comment