Jump to content
Fórum Script Brasil
  • 0

Dúvida em Código



Eu comecei a programar em python a pouco tempo, precisava de ajuda pra resolver esse código. A ideia era pegar nome, e preço de jogos em promoção e mostrar. Na teoria funcionava mais na pratica nada. Se alguém pudesse me ajudar agradeceria. 

import scrapy

import urlparse


class Produto(scrapy.item):

Nome = scrapy.Field()

PrecoInicial = scrapy.Field()

PrecoFinal = scrapy.Field()

DiaTermino = scrapy.Field()

class SteamPromocaoSpider (scrapy.Spider):

name = "steam"

start_urls = ["https://store.steampowered.com"]

def parse(self, response):

body_sel = Selector(response)

urls_jogo = body_sel.xpath("//div[@class='home_page_content']//div[@id='tab_specials_content']//a//@href").extract()

def parse_atracao (self, response):

body_sel = Selector(response)

Nome = self.to_str(body_sel.xpath("//div[@class='game_area_purchase_game']//h1//text()").extract()

PrecoInicial = self.to_str(body_sel.xpath("//div[@class='game_purchase_action']//div[@class='discount_original_price']//text()").extract()

PrecoFinal = self.to_str(body_sel.xpath("//div[@class='game_purchase_action']//div[@class='discount_final_price']//text()").extract()

DiaTermino = self.to_str(body_sel.xpath("//p[@class='game_purchase_discount_countdown']//text()").extract()

def to_str(self, selector):

return selector.extract()[0].encode("utf-8")


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Forum Statistics

    • Total Topics
    • Total Posts
  • Create New...