Created
March 1, 2017 16:04
-
-
Save jroquejr/20870ca5abc322670afff7ea4db160d6 to your computer and use it in GitHub Desktop.
mvper
This file contains hidden or 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
| import re | |
| import scrapy | |
| import textwrap | |
| class MvperSpider(scrapy.Spider): | |
| name = "mvper" | |
| start_urls = ['https://mvp.microsoft.com/en-us/MvpSearch?ex=Microsoft+Azure&sc=s'] | |
| def parse(self, response): | |
| # follow links to mvp user profile pages | |
| #list_profiles = BeautifulSoup(response.body, 'lxml').findAll('div', {'class':'profileListItemFullName'}) | |
| list_profiles = response.selector.css('.profileListItemFullName') | |
| for user in list_profiles: | |
| str_link = user.css('a::attr(href)').extract_first().replace(' ', '%20') | |
| profile_url = u'https://mvp.microsoft.com{}'.format(unicode(str_link)) | |
| yield scrapy.Request(response.urljoin(profile_url), | |
| callback=self.parse_mvp_profile) | |
| # # follow pagination links | |
| # has_next = BeautifulSoup(response.body, 'lxml').findAll('div', {'class':'pager_items'})[0].img['title'] == 'Next' | |
| # if has_next is True: | |
| # next_page = 'https://mvp.microsoft.com' + BeautifulSoup(response.body, 'lxml').findAll('div', {'class':'pager_items'})[0].findAll('a')[1]['href'] | |
| # yield scrapy.Request(next_page, callback=self.parse) | |
| def parse_mvp_profile(self, response): | |
| print(response.url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment