diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml deleted file mode 100644 index f3d4fca..0000000 --- a/.github/workflows/python-app.yml +++ /dev/null @@ -1,39 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python - -name: Python application - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -permissions: - contents: read - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.10 - uses: actions/setup-python@v3 - with: - python-version: "3.10" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest diff --git a/README.md b/README.md index 8c93c8c..c9f22e4 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Copyright (c) 2023 XuangeAha(轩哥啊哈OvO) ## 使用方法 -将需推量的博客地址填入 `urls.txt`放入 `infrc.exe`同目录中,一行一个,以 “#” 开头将作为注释被忽略。双击 `infrc.exe`运行。示例: +将需推量的博客地址填入 `urls.txt` 中,一行一个,以 “#” 开头将作为注释被忽略。示例: ```plaintext # Infrc (Infinite Read-Count 无限阅读量) 推量工具 By 轩哥啊哈OvO @@ -24,17 +24,38 @@ https://xuangeaha.blog.csdn.net/article/details/130655328 # 2023年4月 https://xuangeaha.blog.csdn.net/article/details/130441906 +``` + +接下来,您可以: + +1. 将 `urls.txt` 放入 `infrc.exe` 同目录中,双击 `infrc.exe` 直接运行。 + +2. 或者,将目录加入环境变量中,在终端中输入: +```bash +infrc [文件地址] ``` -可在同目录下的 `config.json`中配置等待时间(默认为30-40秒): +此时,文件名不一定需是 `urls.txt` 。 + +3. 或者,在同目录下的 `config.json` 中配置文件地址: ```json { + "urls": "urls.txt" +} +``` + +此时,文件名也不一定需是 `urls.txt` 。 + +您也可以在 `config.json` 中配置等待时间(默认为30-40秒): + +```json +{ + "urls": "urls.txt", "sleep_time": { "min": 30, "max": 40 } } - ``` diff --git a/build/infrc/infrc.pkg b/build/infrc/infrc.pkg index e6068b0..3d30af6 100644 Binary files a/build/infrc/infrc.pkg and b/build/infrc/infrc.pkg differ diff --git a/build/infrc/warn-infrc.txt b/build/infrc/warn-infrc.txt index 2aaf410..e0c79bf 100644 --- a/build/infrc/warn-infrc.txt +++ b/build/infrc/warn-infrc.txt @@ -15,9 +15,9 @@ IMPORTANT: Do NOT post this list to the issue-tracker. Use it as a basis for tracking down the missing module yourself. Thanks! missing module named 'org.python' - imported by copy (optional) -missing module named pwd - imported by shutil (delayed, optional), tarfile (optional), posixpath (delayed, conditional, optional), subprocess (delayed, conditional, optional), pathlib (delayed, optional), netrc (delayed, conditional), getpass (delayed) -missing module named grp - imported by shutil (delayed, optional), tarfile (optional), subprocess (delayed, conditional, optional), pathlib (delayed, optional) -missing module named posix - imported by shutil (conditional), importlib._bootstrap_external (conditional), posixpath (optional), os (conditional, optional) +missing module named pwd - imported by posixpath (delayed, conditional, optional), shutil (delayed, optional), tarfile (optional), pathlib (delayed, optional), subprocess (delayed, conditional, optional), netrc (delayed, conditional), getpass (delayed) +missing module named grp - imported by shutil (delayed, optional), tarfile (optional), pathlib (delayed, optional), subprocess (delayed, conditional, optional) +missing module named posix - imported by os (conditional, optional), posixpath (optional), shutil (conditional), importlib._bootstrap_external (conditional) missing module named resource - imported by posix (top-level) missing module named _frozen_importlib_external - imported by importlib._bootstrap (delayed), importlib (optional), importlib.abc (optional) excluded module named _frozen_importlib - imported by importlib (optional), importlib.abc (optional) diff --git a/config.json b/config.json index 72ef0dd..2207152 100644 --- a/config.json +++ b/config.json @@ -1,4 +1,5 @@ { + "urls": "urls.txt", "sleep_time": { "min": 30, "max": 40 diff --git a/dist/infrc.exe b/dist/infrc.exe index 559bcbe..cdff945 100644 Binary files a/dist/infrc.exe and b/dist/infrc.exe differ diff --git a/infrc.exe b/infrc.exe index 559bcbe..cdff945 100644 Binary files a/infrc.exe and b/infrc.exe differ diff --git a/infrc.py b/infrc.py index 9afaf86..7f2dc39 100644 --- a/infrc.py +++ b/infrc.py @@ -16,7 +16,7 @@ def get_page(url): if response.status_code == 200: return response.text except requests.RequestException: - _ = input('请求出错:请检查 '+url+' 中是否存在拼写错误...') + _ = input('Infrc002: 请求出错:请检查 '+filepath+' 中 '+url+' 中是否存在拼写错误...') sys.exit() def view_page(url): @@ -27,9 +27,27 @@ def view_page(url): def main(): print("Infrc (Infinite Read-Count 无限阅读量) 推量工具 By 轩哥啊哈OvO") + global filepath while True: '''填入待访问的博客下面刷取四个博客访问量''' - with open("urls.txt", encoding="utf-8") as urls: + try: + with open(sys.argv[1], encoding="utf-8"): pass + filepath = sys.argv[1] + except IndexError: + try: + with open("config.json", encoding="utf-8") as configs: + config = json.load(configs) + filepath = config['urls'] + except FileNotFoundError: + filepath = 'urls.txt' + + try: + with open(filepath, encoding="utf-8"): pass + except: + _ = input("Infrc001: 没有找到 urls.txt 或指定的文件。") + sys.exit() + + with open(filepath, encoding="utf-8") as urls: for url in urls: if url == "\n" or url[0] == "#": continue @@ -41,7 +59,10 @@ def main(): sleep_time_min = config['sleep_time']['min'] sleep_time_max = config['sleep_time']['max'] sleep_time = random.randint(sleep_time_min, sleep_time_max) - except Exception: + except TypeError: + _ = input("Infrc003: config.json 中存在填写错误。") + sys.exit() + except FileNotFoundError: sleep_time = random.randint(30, 40) print('等待', sleep_time, '秒') time.sleep(sleep_time) # 设置访问频率,过于频繁的访问会触发反爬虫