Skip to content

Commit

Permalink
修改了一些BUG,增加了丢失的shopId.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonVanke committed Apr 4, 2021
1 parent 250ba49 commit 359b4de
Show file tree
Hide file tree
Showing 3 changed files with 573,643 additions and 14 deletions.
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,29 @@
![截屏2021-03-08 下午8.20.18](https://github.com/AntonVanke/JDBrandMember/blob/main/readme.img/readme1.png?raw=true)


![截屏2021-03-08 下午8.20.18](https://github.com/AntonVanke/JDBrandMember/blob/main/readme.img/readme2.jpg?raw=true)
![截屏2021-03-08 下午8.20.18](https://github.com/AntonVanke/JDBrandMember/blob/main/readme.img/readme2.jpg?raw=true)

5. ### LICENSE


> MIT License
>
> Copyright (c) 2021 Vanke Anton
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all
> copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
30 changes: 17 additions & 13 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ def brand_member(shop_ID=10000, url=None):
# re.match(r'(\d+)京豆', gift_info.text, re.M | re.I).group(1)
jd = int(re.match(r'(\d+)京豆', gift_info.text, re.M | re.I).group(1))
url_info = [{'url': url, 'gift': jd}]
with open("url.txt", "a", encoding="utf-8") as url_txt_io:
url_txt_io.write(str(url_info) + "\n")
url_txt_io.close()
if shop_ID != 10000:
with open("url.txt", "a", encoding="utf-8") as url_txt_io:
url_txt_io.write(str(url_info) + "\n")
url_txt_io.close()
# 入会
checkbox = browser.find_element_by_xpath('//*[@id="J_brandMember"]/div[2]/div/div[3]/p/span[1]')
if not checkbox.is_selected():
Expand All @@ -104,8 +105,8 @@ def brand_member(shop_ID=10000, url=None):
# 计算获取的京豆
global get_jd
get_jd += jd
if shop_ID != 10000:
print_log("INFO", "入会成功", "获得" + str(jd) + "京豆")
print_log("INFO", "入会成功", "获得" + str(jd) + "京豆")


except Exception as e:
# print_log("ERROR", "入会失败", str(e.args))
Expand All @@ -118,11 +119,14 @@ def fast_task_main():
:return:
"""
# 读取 url.txt
with open("url.txt", "r", encoding="utf-8") as url_txt_io:
url_lists = url_txt_io.readlines()
for url_list in url_lists:
url = json.loads(url_list.split("\n")[0].replace("'", '"'))[0]['url']
brand_member(url=url)
try:
with open("url.txt", "r", encoding="utf-8") as url_txt_io:
url_lists = url_txt_io.readlines()
for url_list in url_lists:
url = json.loads(url_list.split("\n")[0].replace("'", '"'))[0]['url']
brand_member(url=url)
except:
pass


def task_main():
Expand All @@ -132,12 +136,12 @@ def task_main():
"""
# 读取店铺ID
try:
with open("../../Desktop/shopId.txt", "r", encoding="utf-8") as id_file_io:
with open("shopId.txt", "r", encoding="utf-8") as id_file_io:
shop_IDs = id_file_io.readlines()
for shop_ID in shop_IDs:
brand_member(int(shop_ID))
except:
pass
except Exception as e:
print_log("ERROR", "遍历错误", str(e.args))


def login_by_file():
Expand Down
Loading

0 comments on commit 359b4de

Please sign in to comment.