pycharm写一个网页番号获取
时间: 2023-12-15 10:05:46 浏览: 241
首先,你需要安装requests和beautifulsoup4这两个库:
```python
pip install requests
pip install beautifulsoup4
```
然后,你可以使用以下代码来获取网页番号:
```python
import requests
from bs4 import BeautifulSoup
url = "https://www.javbus.com/"
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, 'html.parser')
for movie in soup.find_all('div', class_='item'):
code = movie.a.text
print(code)
```
这段代码将打印出网页上所有的番号。你可以根据自己的需求对代码进行修改。
阅读全文