使用rebbit实现分布式爬虫的例子
数据提取没有很详细,这部分不是重点
# -*- coding:utf-8 -*-
# @Author: YOYO
# @Time: 2018/10/11 10:40
# @说明:
import json
import re
import sys
import threading
import time
import traceback
from os import popen
from lxml import etree
import requests
from rq import send_task, recv_task
reload(sys)
sys.setdefaultencoding('utf8')
class Yhuo(object):
def __init__(self):
self.s=requests.session()
self.headers={
}
self.url_list_queue='url_list_queue'
self.detail_url_queue='detail_url_queue'
self.data_queue='data_queue'
def login(self):
url = "https://yaohuo.me/waplogin.aspx"
payload = "logname=13438&logpass=xxxx&savesid=0&action=login&classid=0&siteid=1000&sid=-3-0-0-0-0&backurl=wapindex.aspx%3Fsiteid%3D1000&g=%E7%99%BB+%E5%BD%95"
headers = {
'accept': "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
'accept-encoding': "gzip, deflate, br",
'accept-language': "zh-CN,zh;q=0.9",
'cache-control': "no-cache",
'content-length': "124",
'content-type': "application/x-www-form-urlencoded",
'origin': "https://yaohuo.me",
'referer': "https://yaohuo.me/waplogin.aspx",