使用python 加代理刷流量

欢迎关注

Python微信订餐小程序课程视频

https://edu.csdn.net/course/detail/36074

Python实战量化交易理财系统

[https://edu.csdn.net/course/detail/35475](

关于刷流量

做开发的有的时候会被拜托一些特殊的业务。 比如说刷票,但是你又不好拒绝,比如你钟情的美女突然有一天拜托你刷票。 这个时候就开发一个刷票工具了。 python 还是非常强大的。非常方便。

使用python

不是使用原生的url2访问,而是使用requests库。 比较方便一点,方便编程。参数比较详细。 参考文档:

http://docs.python-requests.org/zh_CN/latest/

使用一个高级特性代理:

http://docs.python-requests.org/zh_CN/latest/user/advanced.html#proxies

python代码

先安装requests

(venv) $ pip install requests
import requests

for i in range(1, 10):
    proxies = {
        "http": "http://61.164.252.106:139"
    }
    url = "https://www.xxx.com"
    print(url)
    req = requests.get(url, proxies=proxies)
    # 设置编码
    req.encoding = 'utf-8'
    print(req.text)

使用代理服务器访问网站。 这样的ip就变成代理服务器的ip了。 有个问题。代理服务器的ip和端口从哪里查询呢?有个这样的网站 http://www.kuaidaili.com/free/ 上面的代理很好用,反正是用来刷的,搜索些免费的就行。

把上面的代理服务器的ip和端口保存下来然后在配合脚本就可以了。 如果增加参数可以随机几个agent和参数

headers = {
        "User-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2454.85 Safari/537.36"
    }
    req = requests.get(url, headers=headers, params={})

猜你喜欢

转载自blog.csdn.net/huangbangqing12/article/details/121439068