Python Forum
Want to scrape a table data and export it into CSV format
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Want to scrape a table data and export it into CSV format
#1
Hello
I am trying to scrape a table data using the code below .I am trying to scrape the names of all states of USA .I ve managed to extract all 'a'tags but they include all data within a tags .How can i scrape only the names of USA states?
import bs4
import requests
res = requests.get('https://simple.wikipedia.org/wiki/List_of_U.S._states')
soup = bs4.BeautifulSoup(res.text, 'lxml')
soup.select('a')
for i in soup.select('a'):
	print(i.text)
Reply


Messages In This Thread
Want to scrape a table data and export it into CSV format - by tahir1990 - Oct-19-2019, 10:28 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to scrape data from HTML with no identifiers pythonpaul32 2 858 Dec-02-2023, 03:42 AM
Last Post: pythonpaul32
  I am trying to scrape data to broadcast it on Telegram BarryBoos 1 2,121 Jun-10-2023, 02:36 PM
Last Post: snippsat
  Scrape table from multiple pages Nhattanktnn 1 864 Jun-07-2023, 09:35 AM
Last Post: Larz60+
  How can I target and scrape a data-stat never5000 5 2,818 Feb-11-2022, 07:59 PM
Last Post: snippsat
  Scraping data from table into existing dataframe vincer58 1 2,021 Jan-09-2022, 05:15 PM
Last Post: vincer58
  Python Obstacles | American Kenpo | Wiki Scrape URL/Table and Store it in MariaDB BrandonKastning 6 2,856 Dec-29-2021, 12:38 AM
Last Post: BrandonKastning
  Is it possible to scrape this data from Google Searches rosjo 1 2,201 Nov-06-2020, 06:51 PM
Last Post: Larz60+
  Inserting data from a table to another (in same db) firebird 5 2,498 Oct-05-2020, 06:04 AM
Last Post: buran
  Extract data from a table Bob_M 3 2,686 Aug-14-2020, 03:36 PM
Last Post: Bob_M
  Scraping a dynamic data-table in python through AJAX request filozofo 1 3,888 Aug-14-2020, 10:13 AM
Last Post: kashcode

Forum Jump:

User Panel Messages

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