Created
December 31, 2021 02:21
-
-
Save XDo0/1958fe8f7827bb1467b2e19137e57b53 to your computer and use it in GitHub Desktop.
python request a url & Beautifulsoup spider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup,SoupStrainer | |
import requests | |
def crawl_url(keyword): | |
url=f"https://www.google.com/search?q={keyword}" | |
response = requests.get(url) | |
soup = BeautifulSoup(response.content, 'lxml') | |
all_tags=soup.find_all("div",attrs={"data-version-added":True}) | |
# all_catas=soup.find_all(class_="devsite-nav-text") | |
#... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment