Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extractig an score is not there
#4
Use Code Tag
(Apr-09-2022, 10:12 PM)jrotaetxe Wrote: I would like to extract the value of score as a number....
import requests
from bs4 import BeautifulSoup

number = '+12345678'
url = f'https://www.tellows.es/num/{number}'
response = requests.get(url)
soup = BeautifulSoup(response.content, 'lxml')
score = soup.select_one('#tellowsscore > div > a > img')
score_nr = score.attrs['alt'].split(':')[-1].strip()
score_int = int(score_nr.split()[1])
print(score_nr)
print(score_int)
Output:
Score 8 8
Reply


Messages In This Thread
Extractig an score is not there - by jrotaetxe - Apr-09-2022, 03:09 PM
RE: Extractig an score is not there - by snippsat - Apr-09-2022, 04:03 PM
RE: Extractig an score is not there - by jrotaetxe - Apr-09-2022, 10:12 PM
RE: Extractig an score is not there - by snippsat - Apr-09-2022, 11:18 PM
RE: Extractig an score is not there - by jrotaetxe - Apr-10-2022, 08:33 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020