使用python爬虫其实就是方便,它会有各种工具类供你来使用,很方便。Java不可以吗?也可以,使用httpclient工具、还有一个大神写的webmagic框架,这些都可以实现爬虫,只不过python集成工具库,使用几行爬取,而Java需要写更多的行来实现,但目的都是一样。
下面介绍requests库简单使用:
#!/usr/local/env python# coding:utf-8import requests#下面开始介绍requests的使用,环境语言是python3,使用下面的网址作为参考#http://monQuery.do?'#设置请求地址response = requests.get(request_url, headers=headers, proxies=proxy, params=request_param);print(response.status_code)#文本响应内容print(response.text)#json格式响应内容print(response.json())#二进制响应内容print(response.content)#原始格式print(response.raw)