Jan-13-2022, 04:56 AM
(This post was last modified: Jan-13-2022, 04:56 AM by BrandonKastning.
Edit Reason: tag error
)
snippsat,
Thank you for this! This is a great point for me to start regarding images and I believe since you wrote the comment "First Image" that I will need to learn loops. I will be coming back to this.
In the meantime, I ran into some troubles with wikipedia panda table scraping. I changed from Counties to "Municipalities" and regardless of the tables[0], tables[1], tables[2] result in all the wrong data displayed on the wikipedia article.
Code is as follows:
Best Regards,
Brandon Kastning
Thank you for this! This is a great point for me to start regarding images and I believe since you wrote the comment "First Image" that I will need to learn loops. I will be coming back to this.
In the meantime, I ran into some troubles with wikipedia panda table scraping. I changed from Counties to "Municipalities" and regardless of the tables[0], tables[1], tables[2] result in all the wrong data displayed on the wikipedia article.
Code is as follows:
import pandas as pd url = "https://en.wikipedia.org/wiki/List_of_municipalities_in_Alabama" tables = pd.read_html(url) df = tables[1] df.to_excel("AL_Alabama_Municipalities.ods", index=False, engine="odf")Thank you again for this forum! How do I determine the tables[#]? Is it a guessing game or is is there an attribute or property within the browser code that could aid me in finding the correct tables[#]?
Best Regards,
Brandon Kastning
(Jan-10-2022, 06:52 PM)snippsat Wrote:(Jan-09-2022, 09:52 PM)BrandonKastning Wrote: Should I open a new thread?It's part of same task,so no problem.
(Jan-09-2022, 09:52 PM)BrandonKastning Wrote: How to download the map images and store them (Either DB or Local) ?You have to give it try,now need to use more common scraping tool.
Here a demo how to start.
import requests from bs4 import BeautifulSoup url = "https://en.wikipedia.org/wiki/List_of_counties_in_Alabama" response = requests.get(url) soup = BeautifulSoup(response.content, 'lxml') print(soup.find('h1').text) # First image img = soup.find_all('a', class_="image") img_link= img[0].find('img').get('src') img_link = img_link.replace('//', 'http://') print(img_link)
Output:List of counties in Alabama http://upload.wikimedia.org/wikipedia/commons/thumb/5/54/Map_of_Alabama_highlighting_Autauga_County.svg/75px-Map_of_Alabama_highlighting_Autauga_County.svg.png
“And one of the elders saith unto me, Weep not: behold, the Lion of the tribe of Juda, the Root of David, hath prevailed to open the book,...” - Revelation 5:5 (KJV)
“And oppress not the widow, nor the fatherless, the stranger, nor the poor; and ...” - Zechariah 7:10 (KJV)
#LetHISPeopleGo
“And oppress not the widow, nor the fatherless, the stranger, nor the poor; and ...” - Zechariah 7:10 (KJV)
#LetHISPeopleGo