要
爬取网页
服务器IP,可以使用
Python的requests和socket模块:
1. 首先,使用requests模块获取网页内容:
```
python
im
port requests
url = "https://www.example.com"
respo
nse = requests.get(url)
```
2. 然后,从response对象中获取网页的
IP地址:
```
python
im
port socket
ip = socket.gethostbyname(url)
print(
ip)
```
完整代码如下:
```
python
im
port requests
im
port socket
url = "https://www.example.com"
respo
nse = requests.get(url)
ip = socket.gethostbyname(url)
print(
ip)
```