小编use*_*667的帖子

如何使用infinte滚动抓取网站?

我想抓取这个网站.我写了一个蜘蛛,但它只是爬到头版,即前52个项目.

我试过这段代码:

from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector
from scrapy.http import Request
a=[]
from aqaq.items import aqaqItem
import os
import urlparse
import ast

    class aqaqspider(BaseSpider):
        name = "jabong"
        allowed_domains = ["jabong.com"]
        start_urls = [
            "http://www.jabong.com/women/clothing/womens-tops/",
        ]

        def parse(self, response):
            # ... Extract items in the page using extractors
                    n=3
                    ct=1

                    hxs = HtmlXPathSelector(response)
                    sites=hxs.select('//div[@id="page"]')
                    for site in sites:
                            name=site.select('//div[@id="content"]/div[@class="l-pageWrapper"]/div[@class="l-main"]/div[@class="box box-bgcolor"]/section[@class="box-bd pan mtm"]/ul[@id="productsCatalog"]/li/a/@href').extract()
                            print name
                            print ct
                            ct=ct+1
                            a.append(name)
                    req= Request (url="http://www.jabong.com/women/clothing/womens-tops/?page=" + str(n) ,
                    headers = …
Run Code Online (Sandbox Code Playgroud)

javascript scrapy web-scraping python-2.7

5
推荐指数
1
解决办法
1685
查看次数

python读取包含\ x0a的文件,而不是python中的\\ x0a

我有xml文件,其中包含十六进制字符\ x0a.我想将它们转换为适当的unicode字符,如python中的\n.

每当我尝试读取文件时,它都会逃避反斜杠字符.

例如,我的文件内容是

get EtqLt5fwmRBE\x0a
Run Code Online (Sandbox Code Playgroud)

然后在读取文件之后,字符串的表示就出现了

get EtqLt5fwmRBE\\x0a
Run Code Online (Sandbox Code Playgroud)

但我想要的是转换\x0a\n

\x0a文件中没有.还有其他角色.例如repr(),文件中的一行是

\\x7c12\\x7c5\\x7c\\x0a
Run Code Online (Sandbox Code Playgroud)

上面的预期产出是

|12|5|
Run Code Online (Sandbox Code Playgroud)

python unicode python-unicode

-1
推荐指数
1
解决办法
1154
查看次数