Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

loop an array from a html rendered page using python

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading