Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from bs4 import BeautifulSoup
- import requests
- r = requests.get("https://www.ghanayello.com/category/hotels/2/city:Kumasi")
- soup = BeautifulSoup(r.content, "lxml")
- pages = soup.findAll("a", attrs={"class": "pages_no"})
- for page in pages:
- print(page.a["href"])
- # if page.a == None:
- # print("None")
- # else:
- # print(page.a["href"])
- # pg
- # if pg.a is None:
- # print ("1111")
- # else:
- # print("Test")
- tables = soup.findAll("div", attrs={"class": "company"})
- quotes = []
- for row in tables:
- quote = {}
- link = row.find("a")
- if link is None:
- print()
- else:
- quote["name"] = "https://www.ghanayello.com{}".format(row.a["href"])
- quotes.append(quote)
- print(quotes)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement