Skip to content

Commit ba908fc

Browse files
committed
Crawled osu music packs
1 parent 953e301 commit ba908fc

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

WebCrawlers/osu.ppy.sh/getlists.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ def download(url):
2828
print(e)
2929
print('-- trying again: {}'.format(url))
3030
continue
31-
return b
31+
return b.decode("utf-8")
3232

3333

3434
"""
3535
the main function
3636
"""
3737
list_page = download(FULL_LIST)
38+
print(list_page)
3839
propertyDb = PropertyDb()
3940
for match in re.finditer(LIST_PATTERN, list_page, re.DOTALL | re.MULTILINE):
4041
key = match.group(1)
@@ -53,4 +54,5 @@ def download(url):
5354
# if not found
5455
print('-- ERROR not found things on page on key {}: {}'.format(key, current_page))
5556

57+
propertyDb.close()
5658
print('done')

WebCrawlers/osu.ppy.sh/property_db.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,19 @@ def init_db(self):
1717
self.conn.execute('CREATE TABLE IF NOT EXISTS properties (name TEXT PRIMARY KEY, value TEXT, time DATETIME DEFAULT current_timestamp);')
1818

1919

20+
def close(self):
21+
self.conn.close()
22+
23+
2024
def does_record_exist(self, key):
2125
return self.get_value(key) is not None
2226

2327
def save_or_overwrite_data(self, key, value):
2428
self.conn.execute("INSERT OR REPLACE INTO properties(name, value, time) VALUES (?, ?, current_timestamp);", (key, value,))
29+
self.conn.commit()
2530

2631

2732
def get_value(self, key):
28-
self.conn.execute("SELECT * FROM properties WHERE name = ?;", (key,))
29-
return self.conn.fetchone()
33+
cur = self.conn.cursor()
34+
cur.execute("SELECT * FROM properties WHERE name = ?;", (key,))
35+
return cur.fetchone()

WebCrawlers/osu.ppy.sh/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# NOTE: DO NOT COMMIT THIS FILE AFTER FILLING SECRET INFORMATION
22
DB_NAME = 'url.db'
3-
COOKIES = '' # TODO: fill this
3+
COOKIES = 'last_login=YOUR_COOKIES...; osu_site_v=old' # TODO: fill this using the ode style cookie
44
USER_AGENT = 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36'

0 commit comments

Comments
 (0)