python联想关键词
时间: 2023-11-21 17:56:32 浏览: 95
樱花树.zip
根据您提供的引用内容,我可以为您提供两种Python联想关键词的方法:
1.使用Python库进行联想关键词
```python
# 安装pip install googlesearch-python
from googlesearch import search
query = "Python联想关键词"
for j in search(query, num_results=10):
print(j)
```
2.使用Python的requests和BeautifulSoup库进行联想关键词
```python
# 安装pip install requests beautifulsoup4
import requests
from bs4 import BeautifulSoup
query = "Python联想关键词"
url = f"https://www.google.com/search?q={query}"
res = requests.get(url)
soup = BeautifulSoup(res.text, 'html.parser')
for item in soup.select('.kCrYT a'):
print(item.get_text())
```
阅读全文