在Python中查看爬虫的URL可以通过以下几种方法:
1. 使用`requests`库:
```python
import requests
url = "https://example.com/"
response = requests.get(url)
print(response.url) 打印获取的URL
2. 使用`urllib`库:
```python
from urllib.request import urlopen
url = "https://example.com/"
response = urlopen(url)
print(response.geturl()) 打印获取的URL
3. 使用`BeautifulSoup`库:
```python
from bs4 import BeautifulSoup
html = requests.get(url).text 获取网页内容
soup = BeautifulSoup(html, 'html.parser')
urls = [a['href'] for a in soup.find_all('a', href=True)] 提取所有链接
print(urls) 打印提取的URL列表
4. 使用`Selenium`库:
```python
from selenium import webdriver
driver = webdriver.Chrome()
driver.get(url)
print(driver.current_url) 打印当前URL
以上方法可以帮助你在Python爬虫中查看和提取URL。请选择适合你需求的方法进行操作