unknown 2 years ago
commit
4a23b56d25
1 changed files with 30 additions and 0 deletions
  1. 30 0
      main.py

+ 30 - 0
main.py

@@ -0,0 +1,30 @@
+import requests
+from bs4 import BeautifulSoup
+from time import sleep
+
+session = requests.Session()
+text = ''
+with requests.Session() as s:
+    loginurl = 'https://tjupt.org/takelogin.php'
+    logindata = {'username': '用户名',
+                 'password': '密码',
+                 'logout': '7days'}
+    loginreq = s.post(loginurl, data=logindata)
+
+    pageurl = 'https://tjupt.org/torrents.php?inclbookmarked=0&incldead=1&picktype=0&keepseed=0&spstate=0&page=0' # page页码0,1,2,3
+    pagereq = s.get(pageurl)
+    text = pagereq.text
+
+torrenturl = 'https://www.tjupt.org/download.php?id=%s&passkey=你的种子PASSKEY'
+
+soup = BeautifulSoup(pagereq.text, 'html.parser')
+torrents = soup.find_all('table', {'class': 'torrentname'})
+for torrent in torrents:
+    torrent_id = (lambda x : x[x.index('?id=')+4:])(torrent.parent.parent.find_all('a')[1].attrs['href'])
+    torrent_uploading = bool(torrent.parent.parent.find('div', {'class': 'probar_a2'}))
+    torrent_downloading = bool(torrent.parent.parent.find('div', {'class': 'probar_a1'}))
+    torrent_downloaded = bool(torrent.parent.parent.find('div', {'class': 'probar_a3'}))
+    torrent_size = (lambda x : float(x[:-3]) * {'KiB':1/1024, 'MiB':1, 'GiB':1024}[x[-3:]])(torrent.parent.parent.find_all('td', {'class': 'rowfollow'})[-5].text)
+    #print(torrent_id, torrent_uploading, torrent_downloaded, torrent_size)
+    if not torrent_uploading and not torrent_downloading and not torrent_downloaded and torrent_size > 201 and torrent_size < 700:  # 大小
+        print(torrenturl%torrent_id)