Issue
This code showing table empty but it is not because web page filling table with help of some js code.
So I don't know how to parsh it. Please tell me how to parsh it.
import bs4 as bs
import urllib.request
source = urllib.request.urlopen('https://monerobenchmarks.info/').read()
soup = bs.BeautifulSoup(source,'lxml')
table = soup.find('table')
table_rows = table.find_all('tr')
for tr in table_rows:
td = tr.find_all('td')
row = [i.text for i in td]
print(row)
Solution
To use selenium with bs4, try chrome or Firefox driver
from bs4 import BeautifulSoup as Soup
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://monerobenchmarks.info/")
page = Soup(driver.page_source, features='html.parser')
table = page.find('table')
table_rows = table.find_all('tr')
for tr in table_rows:
td = tr.find_all('td')
row = [i.text for i in td]
print(row)
Answered By - 0m3r
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.