marcoswds / tibiabazaar

4 stars 1 forks source link

Adicionar campo com o id da página filtrada #1

Open itsduzao opened 4 years ago

itsduzao commented 4 years ago

Boa tarde,

Eu já utilizei o seu projeto algumas vezes pra filtrar os chars vendidos no market. Uma coisa que eu senti falta fazendo uma pesquisa agora em chars específicos foi o id da página do char. Seria possível adicionar no código uma forma de copiar o link ou só o id de um char ao recolher as outras informações dele. É possível verificar o link do char pelo nome dele ou pelo ícone de lupa na página de histórico de vendas do bazaar. Ajudaria bastante essa feature.

Obrigado por compartilhar o projeto :)

friveraa commented 4 years ago

Try this

in items.py add the following line to add id field to TibiabazzarItem: auction_id = scrapy.Field()

in spiders/tibiabazaar.py add the following line at the beginning of the file: import re

add the following lines anywhere after line "for char in chars:" and before line "items = TibiabazzarItem()"

    char_url = char.css('.AuctionHeader a::attr(href)')[0].get()
    auction_id = re.search('&auctionid=(.*)&', char_url).group(1)

add the following line anywhere after line "items = TibiabazzarItem()" and before line "special_features = char.css(".SpecialCharacterFeatures").extract_first()" items['auction_id'] = auction_id

itsduzao commented 4 years ago

Hello,

It works great.

Thanks for the reply 👍