Skip to main content

Async web scraping framework

Project description

Key Features

  • Provides a web scraping framework used to crawl web pages.
  • Provides data extraction tools used to extract structured data from web pages.

Spider Example

以下是我们的一个爬虫类示例,其作用为爬取 腾讯新闻 首页的”要闻”:

from xpaw import Spider, HttpRequest, Selector, run_spider

class TencentNewsSpider(Spider):
    def start_requests(self):
        yield HttpRequest("", callback=self.parse)

    def parse(self, response):
        selector = Selector(response.text)
        major_news = selector.css("div.major a.linkto").text
        self.log("Major news:")
        for i in range(len(major_news)):
            self.log("%s: %s", i + 1, major_news[i])

if __name__ == '__main__':


  • start_requests: 返回爬虫初始请求。
  • parse: 处理请求得到的页面,这里借助 Selector 及CSS Selector语法提取到了我们所需的数据。


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for xpaw, version 0.10.2
Filename, size File type Python version Upload date Hashes
Filename, size xpaw-0.10.2.tar.gz (172.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page