例如:百度输入ip查看是自己本机的ip,通过UA伪装成其他机器的ip,
爬虫代码:
1 import scrapy 2 3 4 class UatestSpider(scrapy.Spider): 5 name = 'UATest' 6 # allowed_domains = ['www.xxx.com'] 7 start_urls = ['https://www.baidu.com/s?wd=ip'] 8 def parse(self, response): 9 with open('./ip.html','w',encoding='utf-8')as fp: 10 fp.write(response.text) 11 print('over!!!')