2016-09-30 6 views

ответ

1

Похоже, простой запрос AJAX делается для извлечения HTML строки с номерами телефонов:

enter image description here

import re 
import scrapy 

class MySpider(scrapy.Spider): 
    name = 'sophone' 
    start_urls = [ 
     'http://www.freeindex.co.uk/profile(the-main-event-management-company)_266537.htm' 
    ] 

    def parse(self, response): 
     # item id can be extracted from url 
     item_id = re.findall("(\d+)\.htm", response.url)[0] 
     # phone api can be made using this id 
     url = 'http://www.freeindex.co.uk/customscripts' \ 
       '/popup_view_tel_details.asp?id={}'.format(item_id) 
     yield scrapy.Request(url, self.parse_phone) 

    def parse_phone(self, response): 
     from scrapy.shell import inspect_response 
     inspect_response(response, self)