4 Angajamente b1c07b0aeb ... aa9a1c4d33

Autor SHA1 Permisiunea de a trimite mesaje. Dacă este dezactivată, utilizatorul nu va putea trimite nici un fel de mesaj Data
  郑毅 aa9a1c4d33 获取机场三字码 2 luni în urmă
  郑毅 eefa699b17 update 4 luni în urmă
  郑毅 f3fc8b7fe9 update 4 luni în urmă
  郑毅 c098f1ec25 update 4 luni în urmă
4 a modificat fișierele cu 49 adăugiri și 3 ștergeri
  1. 15 0
      .vscode/launch.json
  2. 34 3
      __main__.py
  3. 0 0
      json.json
  4. 0 0
      json1.json

+ 15 - 0
.vscode/launch.json

@@ -0,0 +1,15 @@
+{
+    // 使用 IntelliSense 了解相关属性。 
+    // 悬停以查看现有属性的描述。
+    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
+    "version": "0.2.0",
+    "configurations": [
+        {
+            "name": "Python 调试程序: 当前文件",
+            "type": "debugpy",
+            "request": "launch",
+            "program": "${file}",
+            "console": "integratedTerminal"
+        }
+    ]
+}

+ 34 - 3
__main__.py

@@ -1,8 +1,39 @@
-import time
-
+import requests
+import json
+from bs4 import BeautifulSoup
 
 def main():
-    print('[{}] Hello world!'.format(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))))
+    # print('[{}] Hello world!'.format(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))))
+    # str = '188888'
+    # n = len(str)
+    # new_str = '****' if len(str) <= 4 else str[0:int(n/3)] + '****' + str[int(n*2/3):]
+    # print(new_str)
+
+    result = []
+    n = 290
+    for i in range(1, n):
+        page = i
+        text = requests.get("https://airportcode.bmcx.com/" + str(page) + "__airportcode/")
+        res = text.text
+        soup = BeautifulSoup(res, features="html.parser")
+        arr = soup.find_all(name = "table")[1].find_all(name = "tr")
+        for i in arr[2:]:
+            t = i.find_all(name = "td")
+            href = t[0].find(name = "a").attrs.get("href")
+            if href != None:
+                sub_text = requests.get("https://airportcode.bmcx.com" + href)
+                sub_res = sub_text.text
+                sub_soup = BeautifulSoup(sub_res, features="html.parser")
+                sub_arr = sub_soup.find_all(name = "table")[1].find_all(name = "tr")
+                item = {}
+                for j in sub_arr[2:]:
+                    sub_t = j.find_all(name = "td")
+                    item[sub_t[0].string] = sub_t[1].string
+                result.append(item)
+    s = json.dumps(result, ensure_ascii=False)
+    # print(s)
+    with open('json.json', 'w') as f:
+        f.write(s)
 
 
 # 程序入口

Fișier diff suprimat deoarece este prea mare
+ 0 - 0
json.json


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
json1.json


Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff