吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 20685|回复: 13
收起左侧

[Python 转载] python 爬飞卢小说代码

[复制链接]
寒小凡 发表于 2017-11-11 23:43
import json
import requests
import hashlib
import time
import random
from bs4 import BeautifulSoup
from click._compat import raw_input
s = requests.session()
header = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36',
'Referer':'http://b.faloo.com/'
}

def log():
    url = 'http://u.faloo.com/regist/login.aspx?backurl=http%3A%2F%2Fb.faloo.com%2F'

    zh = raw_input('账号 ')
    mm = raw_input("密码")

    m = random.random()
    yzm = 'http://u.faloo.com/Common/ValIDAteImage.aspx?u=&height=36&width=106&m=' + str(m)
    yz = s.get(url=yzm, headers=header)
    while yz.status_code != 200:
        m = random.random()
        yzm = 'http://u.faloo.com/Common/ValidateImage.aspx?u=&height=36&width=106&m=' + str(m)
        yz = s.get(url=yzm, headers=header)
    open('logo.jpg', 'wb').write(yz.content)
    inyzm = raw_input("yzm")
    ps =mm
    hash = hashlib.md5()
    t = str(int(time.time()))
    jm = 'EW234@![#$&]*{,OP}Kd^w349Op+-32_' + ps + t
    hash.update(jm.encode('utf-8'))
    jm2 = str(hash.hexdigest())
    jm2 = '@345Kie(873_dfbKe>d3<.d23432=' + jm2
    hash = hashlib.md5()
    psw = hash.update(jm2.encode('utf-8'))
    psw = hash.hexdigest()
    data = {
        'txtUserID': zh,
        'txtPwd': str(psw),
        'verifyCode': inyzm,
        'ts': t,
        't': '1'
    }
    a = s.post(url=url, headers=header, data=data)

    a = s.get(url='http://bbs.faloo.com/MyInfo/MesList.aspx', headers=header)
    a.encoding = 'gbk'
    if '选择全部消息'in a.text:
        print('yes')
        select()
    else:
        print('验证码不对')
        log()
        return

def select():
    print('1')
    url = raw_input('url')
    a = s.get(url=url, headers=header)
    a.encoding = 'gbk'
    soup = BeautifulSoup(a.text, 'lxml')
    list = soup.select('.centent a')
    for li in list:
        try:
            url = li.get('href')
            a = s.get(url=url, headers=header)
            a.encoding = 'gbk'
            soup = BeautifulSoup(a.text, 'lxml')
            zw = {
                'title': soup.select('#title h1')[0].text,
                'zw': soup.select('#content')[0].text.replace('\u3000', '').replace('\r', '').replace('\n', '')
            }
            if '您还没有订阅本章节' in zw['zw']:
                print('您还没有订阅本章节')
                select()
                return

            open(zw['title'] + '.txt', 'w+', encoding='utf-8').write(
                json.dumps(zw['title'], ensure_ascii=False) + "\n" + json.dumps(zw['zw'] + "\n",
                                                                                ensure_ascii=False))
            print(zw)
        except:
            print('下载结束 ')
            select()

def main():
    log()

if __name__ == '__main__':
    main()




http://pan.baidu.com/s/1miP3NnE


免费评分

参与人数 2吾爱币 +2 热心值 +2 收起 理由
nanmobei + 1 + 1 热心回复!
娜伤love狠疼 + 1 + 1 谢谢@Thanks!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

zhaoxishm 发表于 2018-1-26 18:55
可惜实用价值并不大
ila 发表于 2017-11-11 23:51 来自手机
娜伤love狠疼 发表于 2017-11-11 23:52
天空里的云 发表于 2017-11-11 23:57 来自手机
嗯嗯,学习了
 楼主| 寒小凡 发表于 2017-11-12 00:00 来自手机
ila 发表于 2017-11-11 23:51
为啥后面加个函数专门调用上一个函数

用来实现循环
糖福禄 发表于 2017-11-12 11:51
小白问下 VIP章节可以下载不
 楼主| 寒小凡 发表于 2017-11-12 11:52
糖福禄 发表于 2017-11-12 11:51
小白问下 VIP章节可以下载不

不可以的欸
ila 发表于 2017-11-30 21:47
我用pycharm,
默认#coding:utf-8
如鱼得金水 发表于 2018-1-26 14:34
这个有啥用?
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-6-1 13:55

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表