-
-
Save razaulhaq/d39ec325d1f075b6572b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scrapy.linkextractors import LinkExtractor | |
from scrapy.selector import Selector | |
class WikispiderSpider(CrawlSpider): | |
name = "wikispider" | |
allowed_domains = ["wikipedia.org"] | |
start_urls = ( | |
'https://en.wikipedia.org/wiki/Mathematics', | |
) | |
rules = ( | |
Rule(LinkExtractor(restrict_xpaths=('//div[@class="mw-body-content"]//a/@href'))), | |
Rule(LinkExtractor(allow=("https://en.wikipedia.org/wiki/",)),callback='parse_item'), | |
) | |
def parse(self, response): | |
hxs = Selector(response) | |
print hxs.xpath('//h1[@class= "firstHeading"]/span/text()').extract() | |
#heading = hxs.select('//h1[@class="firstHeading"]/span/text()').extract() | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment