Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PortalSpider(Spider):
- name = 'portal'
- allowed_domains = ['portal.milvus.com.br']
- start_urls = ['https://portal.milvus.com.br/#/help-desk/chamados/aguardando-atendimento']
- def start_requests(self):
- url = 'https://portal.milvus.com.br/#/help-desk/chamados/aguardando-atendimento'
- self.driver = webdriver.Chrome('D:/Area de trabalho/milvus/milvus/chromedriver')
- self.driver.get('https://portal.milvus.com.br/#/login')
- sleep(5)
- username = self.driver.find_element_by_id("username")
- password = self.driver.find_element_by_id("password")
- username.send_keys("111111")
- password.send_keys("111111")
- self.driver.find_element_by_xpath('//button').click()
- sleep(5)
- self.driver.find_element_by_xpath('//*[@id="page-heading"]/div[3]/div/div[1]/div[1]/div[1]/a/div[1]/span').click()
- sleep(5)
- #sel = Selector(text=self.driver.page_source)
- yield self.make_requests_from_url(url)
- def parse(self, response):
- chamados = response.xpath('//*[@id="table-chamados"]/tbody/tr/td//@href').extract()
- for chamado in chamados:
- url = 'https://portal.milvus.com.br/' + str(chamado)
- print(self.make_requests_from_url(url))
- yield Request(url, callback=self.parse_chamado)
- #next_page = sel.xpath('//a[text()="Próximo"]/@href').extract()
- #url_next = 'https://portal.milvus.com.br/'+ next_page
- #yield Request(url_next)
- def parse_chamado(self, response):
- chamado = response.xpath('//*[@id="page-heading"]/h1/text()').extract()
- unidade = response.xpath('//*[@id="wrap"]/div/form/div[2]/div/div[2]/div/div[1]/div[1]/div/div[1]/div/div[1]/div/div[2]/select-padrao/div/div/a/span[2]/span/text()').extract()
- categoria_pri = response.xpath('//*[@id="wrap"]/div/form/div[2]/div/div[2]/div/div[1]/div[1]/div/div[1]/div/div[2]/div/div[2]/select-padrao/div/div/a/span[2]/span/text()').extract()
- categoria_sec = response.xpath('//*[@id="wrap"]/div/form/div[2]/div/div[2]/div/div[1]/div[1]/div/div[1]/div/div[2]/div/div[3]/select-padrao/div/div/a/span[2]/span/text()').extract()
- tecnico = response.xpath('//*[@id="wrap"]/div/form/div[2]/div/div[2]/div/div[1]/div[1]/div/div[1]/div/div[2]/div/div[4]/select-padrao/div/div/a/span[2]/span/text()').extract_first()
- yield{'chamado':chamado,
- 'unidade': unidade,
- 'categoria principal':categoria_pri,
- 'categoria secundaria':categoria_sec,
- 'tecnico':tecnico}
Add Comment
Please, Sign In to add comment