Python Forum
Help Scraping links and table from link
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Scraping links and table from link
#11
(Oct-11-2023, 07:08 AM)cartonics Wrote: my first idea was to take only the tags widget-results__team-name match-name and btn btn-primary btn-xs

is there something to achieve that?
>>> tag = tr[2].find(class_="widget-results__team-name match-name")
>>> tag
<span class="widget-results__team-name match-name" data-original-title="Verona" data-placement="bottom" data-toggle="tooltip">Verona</span>
>>> tag.text
'Verona'

>>> tag.attrs
{'class': ['widget-results__team-name', 'match-name'],
 'data-original-title': 'Verona',
 'data-placement': 'bottom',
 'data-toggle': 'tooltip'}
>>> tag.get('data-original-title')
'Verona'
(Oct-11-2023, 07:08 AM)cartonics Wrote: if there is more than one table in link for example here.
https://www.sbostats.com/soccer/league/i...-c-group-c
is it possible to scrape only the second one
It's only one table with a Title as separator,can go in take out singels vaules.
from bs4 import BeautifulSoup
import requests

parser = 'lxml'  # or 'lxml' (preferred) or 'html5lib', if installed
resp = requests.get("https://www.sbostats.com/soccer/league/italy/serie-c-group-c")
soup = BeautifulSoup(resp.content, parser)
Teste code over:
>>> soup.select_one('tr:nth-child(7)').text
'  ACR Messina   STATS        Casertana      2.38   3.00   2.90  '
>>> soup.select_one('tr:nth-child(10)').text
'  Monterosi   STATS        Audace Cerignola      2.63   3.10   2.50  '
So here use CSS selctor and take out only wanted tags.
Take a look at Web-Scraping part-1.
cartonics likes this post
Reply
#12
Quote:So here use CSS selctor and take out only wanted tags.
Take a look at Web-Scraping part-1.

awesome link with examples.. also part2 a lot of things to study!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Scraping data from table into existing dataframe vincer58 1 2,028 Jan-09-2022, 05:15 PM
Last Post: vincer58
  Need help scraping wikipedia table bborusz2 6 3,269 Dec-01-2020, 11:31 PM
Last Post: snippsat
  Web Scraping Inquiry (Extracting content from a table in asubdomain) DustinKlent 3 3,736 Aug-17-2020, 10:10 AM
Last Post: snippsat
  Scraping a dynamic data-table in python through AJAX request filozofo 1 3,897 Aug-14-2020, 10:13 AM
Last Post: kashcode
  scraping multiple pages from table bandar 1 2,717 Jun-27-2020, 10:43 PM
Last Post: Larz60+
  get link and link text from table metulburr 5 6,308 Jun-13-2019, 07:50 PM
Last Post: snippsat
  webscrapping links and then enter those links to scrape data kirito85 2 3,227 Jun-13-2019, 02:23 AM
Last Post: kirito85
  Error while scraping links with beautiful soup mgtheboss 4 8,396 Dec-22-2017, 12:41 PM
Last Post: mgtheboss
  Web scraping "fancy" table acehole60 2 4,923 Dec-16-2016, 09:17 AM
Last Post: acehole60

Forum Jump:

User Panel Messages

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