I want to scrape from multiple websites with similar url's such as https://woollahra.ljhooker.com.au/our-team, https://chinatown.ljhooker.com.au/our-team and https://bondibeach.ljhooker.com.au/our-team.
I have already written a script that works for the first website, however I am unsure how to tell it to scrape from the other two websites.
My code:
from urllib.request import urlopen as uReq from bs4 import BeautifulSoup as soup my_url = "https://woollahra.ljhooker.com.au/our-team" page_soup = soup(page_html, "html.parser") containers = page_soup.findAll("div", {"class":"team-details"}) for container in containers: agent_name = container.findAll("div", {"class":"team-name"}) name = agent_name[0].text phone = container.findAll("span", {"class":"phone"}) mobile = phone[0].text print("name: " + name) print("mobile: " + mobile) Is there a way that I can simply list the different part of the url (woollahra, chinatown, bondibeach), so that the script will loop through each webpage using the code I have already written?
lxmlas the parser, to improve performance. You can also useSoupStrainerto only parse relevant segments of the source, to further improve performance.