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

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2224|回复: 14
收起左侧

[讨论] 起点跑不起来 换了一个网站练手crawlspider 正则还是不会用还是xpaths跑起来的

[复制链接]
lihu5841314 发表于 2021-5-31 19:40
[Asm] 纯文本查看 复制代码
import scrapy
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import CrawlSpider, Rule


class KsSpider(CrawlSpider):
    name = 'ks'
    allowed_domains = ['sxcnw.net']
    start_urls = ['http://www.sxcnw.net/xuanhuan/List_1.html']

    rules = (
        Rule(LinkExtractor(restrict_xpaths='//ul[@class="listcon"]/li/a'), callback='parse_item'),   #到最后一个标签比如这个a标签之后不要自己往下去取url  坑了我好久  rules会自动提取最后一个标签里的url
        Rule(LinkExtractor(restrict_xpaths='//div[@class="showpage"]/a[position()>1]'),follow=True),
    )

    def parse_item(self, response):
        item = {}
        item['book_name'] = response.xpath('//div[@class="book-title clear"]/h1/text()').extract()
        item['content'] = response.xpath('//div[@class="about-txt"]//text()').extract()
        item['book_down'] = response.xpath('//div[@class="dl-to-pc"]/a/@href').extract_first()
        print(item)
        return item

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

 楼主| lihu5841314 发表于 2021-5-31 19:49
mysql  和  manggo  pandas  web  前端  该先看那个又没建议的  小白零基础
satukenny 发表于 2021-5-31 20:07
zuijianren 发表于 2021-5-31 20:08
自学的话,我觉得先搞前端好,上手快,兴趣起得来,sql语句前期会几句简单的就好,搜都能搜得到。
前端学了,你能自己写个小插件小网站什么的,很有成就感的,个人体验。
 楼主| lihu5841314 发表于 2021-5-31 20:10
zuijianren 发表于 2021-5-31 20:08
自学的话,我觉得先搞前端好,上手快,兴趣起得来,sql语句前期会几句简单的就好,搜都能搜得到。
前端学 ...

关键好学不  前期学pygame 坑了我半个月  只能做得破飞机  还老出BUG
zuijianren 发表于 2021-5-31 20:16
lihu5841314 发表于 2021-5-31 20:10
关键好学不  前期学pygame 坑了我半个月  只能做得破飞机  还老出BUG

你说的是这个前端啊,那我不知道了,我python不熟
darling995 发表于 2021-5-31 20:52
以前学了一段时间,但是没学会
1039468583 发表于 2021-5-31 21:58
zuijianren 发表于 2021-5-31 20:16
你说的是这个前端啊,那我不知道了,我python不熟

可以熟悉一下h5 js css 那些 然后配合python的Django 写出一个网站
艾破解 发表于 2021-5-31 21:59
zuijianren 发表于 2021-5-31 20:08
自学的话,我觉得先搞前端好,上手快,兴趣起得来,sql语句前期会几句简单的就好,搜都能搜得到。
前端学 ...

是吗是吗,感觉会好有趣
a525 发表于 2021-5-31 22:46
lihu5841314 发表于 2021-5-31 19:49
mysql  和  manggo  pandas  web  前端  该先看那个又没建议的  小白零基础

没有一个具体方向吗?
您需要登录后才可以回帖 登录 | 注册[Register]

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

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

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

GMT+8, 2024-5-3 05:59

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

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