Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def scrape_nairaland():
- headers = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"}
- r = requests.get("https://nairaland.com", headers=headers)
- soup = BeautifulSoup(r.content, "html.parser")
- links = [item.get("href") for item in soup.find("td", class_="featured").find_all("a")][:65]
- links_text = [item.text for item in soup.find("td", class_="featured").find_all("a")][:65]
- return {
- "links_data":zip(links_text, links)
- }
Advertisement
Add Comment
Please, Sign In to add comment