There is a page that contains more than one table. I would like to scrape any table whatever I want.
I have noticed that using the code below I receive only access to the first table:
import requests
import lxml.html as lh
url= 'some url'
page = requests.get(url)
doc = lh.fromstring(page.content)
tr_elements = doc.xpath('//tr')
for t in tr_elements[0]:
name=t.text_content()
print(name)
According to the answers included in How can I find an element by CSS class with XPath? i was trying to do the following in order to get access to the other table. I have written
doc.xpath('//*[contains(@class, 'some name of the class')]//tr')
instead of just
doc.xpath('//tr')
. However this gave me no result. I must admit that my knowledge of using xpath is very low, so I would like to receive an answer instead of just informing me that someone has asked a similar question.
Thank you in advanced for help.
EDIT:
here is the url: https://biznes.interia.pl/gieldy/notowania-gpw/profil-akcji-mab,wId,6852,tab,przebieg-sesji