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.

44 lines
1.1 KiB

# -*- coding: utf-8 -*-
from lxml import etree
import settings
import downloader
3 years ago
def myreplace(text):
return text.strip().replace(' ', '').replace("\r\n", '')
class historyPriceItem:
def __init__(self, id):
3 years ago
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
3 years ago
# tree = etree.tostring(response.xpath(reg)[0], encoding = 'utf-8', method = 'html').decode('utf-8')
if __name__ == '__main__':
3 years ago
id = "10036840192083"
aitem = historyPriceItem(id)
aitem.gethistoryPrice()