Commit 9fa03841 by lichenggang

df

parent a3380642
......@@ -3,4 +3,4 @@
*.log
venv
.idea
__pycache__
__pycache__
No preview for this file type
No preview for this file type
......@@ -10,12 +10,12 @@ headers = {
"Cache-Control": "max-age=0",
"Connection": "keep-alive",
"Host": "www.chip1stop.com",
"Referer": "https://www.chip1stop.com/CHN/zh",
"Referer": "https://www.chip1stop.com/HKG/zh",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36"
}
domain = 'https://www.chip1stop.com'
catelist_url = 'https://www.chip1stop.com/CHN/zh/category'
catelist_url = 'https://www.chip1stop.com/HKG/zh/category'
item_name_pattern = re.compile(r'([^(]*)(')
item_num_pattern = re.compile(r'[^(]*((\d*,*\d*,*\d+))')
var = {
......
......@@ -10,12 +10,12 @@ headers = {
"Cache-Control": "max-age=0",
"Connection": "keep-alive",
"Host": "www.chip1stop.com",
"Referer": "https://www.chip1stop.com/CHN/zh",
"Referer": "https://www.chip1stop.com/HKG/zh",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36"
}
domain = 'https://www.chip1stop.com'
catelist_url = 'https://www.chip1stop.com/CHN/zh/stock'
catelist_url = 'https://www.chip1stop.com/HKG/zh/stock'
item_name_pattern = re.compile(r'([^\[]*)')
item_num_pattern = re.compile(r'\[([0-9,]*)\]')
var = {
......
......@@ -88,8 +88,8 @@ def parse_text(text):
obj['from'] = fm[0].text.strip() if fm else ''
stock = tr.xpath('.//p[@class="m-font-b"][2]')
obj['goods_number'] = int(stock[0].text.replace('库存数:', '').replace(',', '')) if stock else 0
obj['min_buynum'] = tr.xpath('.//td[3]//input[2]/@value')[0] if tr.xpath('.//td[3]//input[2]/@value') else 1
obj['increment'] = tr.xpath('.//td[3]//input[3]/@value')[0] if tr.xpath('.//td[3]//input[3]/@value') else 1
obj['min_buynum'] = int(tr.xpath('.//td[3]//input[2]/@value')[0]) if tr.xpath('.//td[3]//input[2]/@value') else 1
obj['increment'] = int(tr.xpath('.//td[3]//input[3]/@value')[0]) if tr.xpath('.//td[3]//input[3]/@value') else 1
price_doms = tr.xpath('.//td[4]//tbody//tr')
obj['prices'] = []
if price_doms:
......@@ -97,7 +97,7 @@ def parse_text(text):
per = dict()
per_price = price_dom.xpath('.//td')
per['purchases'] = int(per_price[0].xpath('./text()')[0].replace('+', '').replace(',', ''))
per['price'] = float(per_price[1].xpath('./text()')[0].replace('¥', '').replace(',', '').strip())
per['price'] = float(per_price[1].xpath('./text()')[0].replace('US$', '').replace(',', '').strip())
obj['prices'].append(per)
product_list.append(obj)
return product_list
......@@ -133,7 +133,7 @@ def parse_text1(text):
per = dict()
per_price = price_dom.xpath('.//td')
per['purchases'] = int(per_price[0].xpath('./text()')[0].replace('+', '').replace(',', ''))
per['price'] = float(per_price[1].xpath('./text()')[0].replace('¥', '').replace(',', '').strip())
per['price'] = float(per_price[1].xpath('./text()')[0].replace('US$', '').replace(',', '').strip())
obj['prices'].append(per)
return obj
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment