服务器采集
使用服务器采集有两大原因
(1)大规模爬虫的需要
(2)防止IP地址被封杀
使用动态IP拨号服务器
拨号上网有一个独特的特点,就是每次拨号都会换一个新的IP地址。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@File : ServerPythonIP.py
@Author: Xinzhe.Pang
@Date : 2019/7/15 22:54
@Desc :
"""
import os
import time
g_adsl_account = {"name": "adsl",
"username": "...",
"password": "..."}
class Adsl(object):
# init : name : adsl名称
def __init__(self):
self.name = g_adsl_account["name"]
self.username = g_adsl_account["username"]
self.password = g_adsl_account["password"]
# connect : 宽带拨号
def connect(self):
cmd_str = "rasdial %s %s %s" % (self.name, self.username, self.pass