Skip to content

Commit

Permalink
Merge pull request #20 from grtfou/dev-imp
Browse files Browse the repository at this point in the history
close: #19 bug fixing
  • Loading branch information
grtfou committed Dec 21, 2015
2 parents 73f0b2c + 756db41 commit 16a2f63
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
A web crawler that visit [755 website][1] for download photo and video.

## Requirements
* Python == 3.5
* Python == 3.4
* aiohttp >= 0.18.4
* cchardet >= 1.0.0
* chardet >=2.3.0
* requests >= 2.8.1

## How to Use
Expand All @@ -18,9 +18,12 @@ $ python crawler.py [url] [stop time (yy/mm/dd)]
$ python crawler.py http://7gogo.jp/talks/YtykfykuJfMT 141105
```
#### [GUI]
TODO
Please install [Kivy][2] in your platform.

You could see **requirements_gui.txt** to check Kivy libraries.

## Licence
MIT License

[1]: http://7gogo.jp "755"
[2]: http://kivy.org "kivy"
12 changes: 7 additions & 5 deletions crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ def run(self, client, talk_id, username, stop_time=0):
video_count = 1
last_image_t = 0
last_video_t = 0
for post_rec in range(1, 99999999, 100):
post_rec = 1
while True:
payload = {
'direction': 'NEXT',
'limit': page_limit,
'postId': post_rec, # test 6000 (photos and videos)
'postId': post_rec,
'talkId': talk_id,
}
post_rec += page_limit

r = self.session.get(self.url, params=payload)
if r.status_code != 200:
Expand All @@ -89,9 +91,9 @@ def run(self, client, talk_id, username, stop_time=0):
return

# Created directories for store files
dest_img_path = 'downloads{}{}{}'.format(
dest_img_path = 'downloads{}{}{}{}'.format(
os.sep, username, os.sep, self.img_path)
dest_video_path = 'downloads{}{}{}'.format(
dest_video_path = 'downloads{}{}{}{}'.format(
os.sep, username, os.sep, self.video_path)
if not os.path.isdir(dest_img_path):
os.makedirs(dest_img_path)
Expand Down Expand Up @@ -153,7 +155,7 @@ def run(self, client, talk_id, username, stop_time=0):
args.stop_time = time.mktime(time.strptime(args.stop_time, "%y%m%d"))
except ValueError:
parser.print_help()
print('Error: Stop time format')
print('Error: Stop Date format is wrong')
sys.exit()

my_cwawler = Crawler()
Expand Down
13 changes: 9 additions & 4 deletions main.kv
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
id: btn_start
text: 'Start'
size_hint: None, None
pos_hint: {'center_x':.8, 'center_y': .2}
pos_hint: {'center_x':.7, 'center_y': .35}
on_press: root.check_status(url.text, stop_date.text)

Label:
Expand All @@ -26,10 +26,15 @@
TextInput:
id: url
text: 'http://7gogo.jp/talks/YtykfykuJfMT'
size_hint: .25, .05
pos_hint: {'center_x':.38, 'center_y': .8}
focus: True
multiline: False
size_hint: .35, .05
pos_hint: {'center_x':.45, 'center_y': .8}
font_size: min(self.height, self.width) / 2
TextInput:
id: stop_date
text: '141011'
multiline: False
size_hint: .25, .05
pos_hint: {'center_x':.38, 'center_y': .6}
pos_hint: {'center_x':.40, 'center_y': .6}
font_size: min(self.height, self.width) / 2
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time

import aiohttp
import asyncio
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.core.window import Window

from crawler import Crawler
from talk_id import get_talk_id
Expand Down Expand Up @@ -38,4 +37,5 @@ def build(self):
return CrawlerWidget()

if __name__ == '__main__':
Window.size = (700, 600)
MainApp().run()

0 comments on commit 16a2f63

Please sign in to comment.