65 lines
2.2 KiB
Python
65 lines
2.2 KiB
Python
import requests
|
|
import re
|
|
import json
|
|
|
|
url = "https://auto.51autoshop.com/Customer/CustCardList"
|
|
headers = {
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
'Cookie': 'Hm_lvt_b13246fd95aec7bfc57d9c415dfefe18=1733898115; __RequestVerificationToken=W1tpkb8doRLe28rYbhoVDiAF5kxH7vis6yUPWbL8CHIkABRM1QBjNpE3WV72mklwY9snog2sP0b_wz9NAevw5AV38-U1; HMACCOUNT=ABFCA62083E00432; LoginInfo=2412349ad7894c01b66cd10b894ff2d4; GetShopValidity=1; SERVERID=df24b70122439a42ff2eaa4b483d47a0|1733971685|1733934764; Hm_lpvt_b13246fd95aec7bfc57d9c415dfefe18=1733971687',
|
|
'Origin': 'https://auto.51autoshop.com',
|
|
'Priority': 'u=0, i',
|
|
'Referer': 'https://auto.51autoshop.com/Customer/CustCardList',
|
|
'Sec-Ch-Ua': '"Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
|
|
'Sec-Ch-Ua-Mobile': '?0',
|
|
'Sec-Ch-Ua-Platform': '"Windows"',
|
|
'Sec-Fetch-Dest': 'iframe',
|
|
'Sec-Fetch-Mode': 'navigate',
|
|
'Sec-Fetch-Site': 'same-origin',
|
|
'Sec-Fetch-User': '?1',
|
|
'Upgrade-Insecure-Requests': '1',
|
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0'
|
|
}
|
|
data = {
|
|
'__RequestVerificationToken': '1OTyeT2u_1P6DQTBCMLDs1jTbEE4FmnXbz1d2N9-wox36wkGAkIKCcyXZkl9KW2BcGsW0lZjb6QDGcwQoryIiBme-Z81',
|
|
'Keywords': '',
|
|
'StartTime': '',
|
|
'EndTime': '',
|
|
'WCompanyID': '',
|
|
'ExpiredOnly': 'false',
|
|
'DetialUrl': '/Customer/CustCardDetial',
|
|
'PageIndex': '1',
|
|
'PageSize': '10000',
|
|
'SortField': '',
|
|
'SortDir': '',
|
|
'IsExpired': '',
|
|
'CompanyName': ''
|
|
}
|
|
|
|
res = requests.post(url, data=data, headers=headers)
|
|
html_text = res.text
|
|
|
|
|
|
import re
|
|
import pandas as pd
|
|
text = '''
|
|
"CustCardID": 710943,
|
|
"OtherField": "SomeValue",
|
|
"CustCardID": 123456,
|
|
"CustCardID": 987654,
|
|
'''
|
|
|
|
pattern = r'"CardCode":\s*"([^"]+)"'
|
|
pattern1 = r'"CustCardID":(\d+)'
|
|
|
|
matches1 = re.findall(pattern1, html_text)
|
|
matches = re.findall(pattern, html_text)
|
|
print(matches) # 输出: ['710943', '123456', '987654']
|
|
|
|
# 将匹配结果转换为 DataFrame
|
|
df = pd.DataFrame(matches, columns=['CardCode'])
|
|
df.to_excel('CardCode.xlsx', index=False)
|
|
df1 = pd.DataFrame(matches1, columns=['CustCardID'])
|
|
|
|
# 将 DataFrame 保存为 Excel 文件
|
|
df1.to_excel('CardCode1.xlsx', index=False)
|