I am scraping on python data from a rendered web page using requests html. My code works fine to show just one result, but I’d like to loop it to get all data.
This is my code:
import requests_html
matchlink = 'https://www.betexplorer.com/football/germany/3-liga/results/'
from requests_html import HTMLSession
session = HTMLSession()
r = session.get(matchlink)
r.html.render(timeout=20)
allmatch = r.html.find('.in-match')
match = allmatch[0].text
print(match)
I am a newbie of python, I thought to use a loop FOR but I don’t know exactly how to set it
>Solution :
you can use a for loop to iterate over the allmatch list!
import requests_html
matchlink = 'https://www.betexplorer.com/football/germany/3-liga/results/'
from requests_html import HTMLSession
session = HTMLSession()
r = session.get(matchlink)
r.html.render(timeout=20)
allmatch = r.html.find('.in-match')
for match in allmatch:
print(match.text)