Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug and add some option. #21

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix some naming errors .
  • Loading branch information
Murlors committed Jan 20, 2023
commit 17850f249589a490da5761dd671affeeb24c12f5
1 change: 1 addition & 0 deletions pixiv_crawler/collector/collector_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def collect(args: Tuple[str, Callable, Optional[Dict]]) \
generic metadata collector, collect metadata from templates
e.g.: user.json, page.json, ...
use different selector to select different elements
args: url, selector, additional_headers
"""
url, selector, additional_headers = args
headers = NETWORK_CONFIG["HEADER"]
Expand Down
2 changes: 1 addition & 1 deletion pixiv_crawler/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
MODE_CONFIG = {
# start date
"START_DATE": datetime.date(2022, 8, 5),
# date range: [start, start + domain - 1]
# date range: [start, start + range - 1]
"RANGE": 1,

# which ranking list
Expand Down
6 changes: 3 additions & 3 deletions pixiv_crawler/crawlers/ranking_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ def __collect(self):
ARTWORK_PER = 50
n_page = (MODE_CONFIG["N_ARTWORK"] - 1) // ARTWORK_PER + 1 # ceil

def addData(current: datetime.date, days):
def addDate(current: datetime.date, days):
return current + datetime.timedelta(days)

printInfo(f"===== start collecting {self.mode}:{self.content} ranking =====")
printInfo("from {} to {}".format(
self.date.strftime("%Y-%m-%d"),
addData(self.date, self.range - 1).strftime("%Y-%m-%d")))
addDate(self.date, self.range - 1).strftime("%Y-%m-%d")))

urls: Set[str] = set()
for _ in range(self.range):
for i in range(n_page):
urls.add(self.url.format(
self.date.strftime("%Y%m%d"), i + 1))
self.date = addData(self.date, 1)
self.date = addDate(self.date, 1)

n_thread = DOWNLOAD_CONFIG["N_THREAD"]
with futures.ThreadPoolExecutor(n_thread) as executor:
Expand Down
2 changes: 1 addition & 1 deletion pixiv_crawler/downloader/download_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def downloadImage(url: str, save: bool=True, sub_folder:str=None):
if response.status_code == 200:
image_size = int(
response.headers["content-length"])
# deletc incomplete image
# detect incomplete image
if len(response.content) != image_size:
time.sleep(DOWNLOAD_CONFIG["FAIL_DELAY"])
wait_time += 2
Expand Down