You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
from lxml import etree
|
|
|
|
import settings
|
|
|
|
import downloader
|
|
|
|
|
|
|
|
def myreplace(text):
|
|
|
|
return text.strip().replace(' ', '').replace("\r\n", '')
|
|
|
|
|
|
|
|
class historyPriceItem:
|
|
|
|
def __init__(self, id):
|
|
|
|
self.url = settings.HISTORY_PRICE_URL + str(id)
|
|
|
|
# self.response = downloader.useRequests(self.url)
|
|
|
|
self.response = etree.parse('historyPrice.html', etree.HTMLParser(encoding = 'utf-8'))
|
|
|
|
|
|
|
|
def gethistoryPrice(self) -> list:
|
|
|
|
|
|
|
|
reg = r"//div[@class='container']"
|
|
|
|
item = self.response.xpath(reg)[0]
|
|
|
|
item = etree.tostring(item, encoding = 'utf-8', method = 'html').decode('utf-8')
|
|
|
|
|
|
|
|
def getTag(self) -> str:
|
|
|
|
reg = r"//div[@data-content='商品类别:']/text()"
|
|
|
|
tag = self.response.xpath(reg)[0]
|
|
|
|
tag = etree.HTML(tag)
|
|
|
|
tag = myreplace(tag)
|
|
|
|
return tag[5:]
|
|
|
|
|
|
|
|
def get
|
|
|
|
|
|
|
|
# tree = etree.tostring(response.xpath(reg)[0], encoding = 'utf-8', method = 'html').decode('utf-8')
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
id = "10036840192083"
|
|
|
|
aitem = historyPriceItem(id)
|
|
|
|
aitem.gethistoryPrice()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|