Home > database >  Is selenium recommended for web scraping in my case?
Is selenium recommended for web scraping in my case?

Time:09-16

I start in the web scraping and I am looking for a way to find the postal codes of a company list, using Python and web scraping.

For this I want to use the pandas library since my file is in excel format with the selenium library to search the internet for postal codes corresponding to companies.

For example, in the A column there is company_1. So the algorithm must search for "company_1" on the internet and return the corresponding postal code in the B column of Excel. The difficulty is that I don't have a website to associate for each company.

Is that possible ?

Thanks in advance

CodePudding user response:

Easiest way to achieve what you need is with geocoding - Python has a library called GeoPy for that purpose

# importing geopy library
from geopy.geocoders import Nominatim
 
# calling the Nominatim tool
loc = Nominatim(user_agent="GetLoc")
 
# entering the location name
getLoc = loc.geocode("Wawel, Kraków", addressdetails=True)
 
# printing post code
print(getLoc.raw['address']['postcode'])

Webscraping is not a good solution, because you need to extract specific piece of information without knowing any of the sites' structures.

  • Related