jeudi 24 septembre 2020

Webscraper in Python

My question is if it is possible to get a number that is inside a span like this:

<html junk>
 <div class="test">
     <span>
     55
     </span>
 </div>
</html junk>

As you can see the span has no class or id.

My current code which is just the default code for a scraper (removed User-Agent and URL):

import requests
from bs4 import BeautifulSoup

URL = ''

headers = {"User-Agent": ''}

page = requests.get(URL, headers=headers)

soup = BeautifulSoup(page.content, 'html.parser')

#Here is where the "55" should be found (the number is going to change over time so im not excactly looking for it
title = soup.find('') 

print(title)




Aucun commentaire:

Enregistrer un commentaire