Question: This is a python project I am working on. How would I get rid of the hrefs for twitter? I am using python and beautiful
This is a python project I am working on. How would I get rid of the hrefs for twitter? I am using python and beautiful soup to scrape a website but I only want the links for the articles not a twitter link to show up in my array. import requests from bs4 import BeautifulSoup, SoupStrainer URL = 'https://www.usnpl.com/search/state?state=MI#section-D' page = requests.get(URL) soup = BeautifulSoup(page.content, 'html.parser') links = SoupStrainer('a') #Find a way to filter out facebook classes with i tag websites = soup.find_all(class_="w-10" ) a= [] for tag in websites: tdTags = tag.find_all("a") if tdTags: a.append(tdTags) for x in a: print(x)
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
