Skip to content

Commit

Permalink
终端中启动infrc或config.json配置
Browse files Browse the repository at this point in the history
  • Loading branch information
Xuangeaha committed May 21, 2023
1 parent 5f80d9e commit 704ce5c
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 48 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/python-app.yml

This file was deleted.

27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Copyright (c) 2023 XuangeAha(轩哥啊哈OvO)

## 使用方法

将需推量的博客地址填入 `urls.txt`放入 `infrc.exe`同目录中,一行一个,以 “#” 开头将作为注释被忽略。双击 `infrc.exe`运行。示例:
将需推量的博客地址填入 `urls.txt`,一行一个,以 “#” 开头将作为注释被忽略。示例:

```plaintext
# Infrc (Infinite Read-Count 无限阅读量) 推量工具 By 轩哥啊哈OvO
Expand All @@ -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
}
}

```
Binary file modified build/infrc/infrc.pkg
Binary file not shown.
6 changes: 3 additions & 3 deletions build/infrc/warn-infrc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"urls": "urls.txt",
"sleep_time": {
"min": 30,
"max": 40
Expand Down
Binary file modified dist/infrc.exe
Binary file not shown.
Binary file modified infrc.exe
Binary file not shown.
27 changes: 24 additions & 3 deletions infrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand All @@ -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) # 设置访问频率,过于频繁的访问会触发反爬虫
Expand Down

0 comments on commit 704ce5c

Please sign in to comment.