qgyd2021 commited on
Commit
3ea6a16
1 Parent(s): 2d11779

[update]add main

Browse files
data/product.jsonl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:651e91056971358dc9a6d83a59aa798e33de74f8bdcb49d98c16046b984d1073
3
- size 1330136
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f9fe1700d6dccc6b18b79c5a5962624ff1cded68aaa4ef35986fbd6976f9f4bd
3
+ size 1349119
examples/range_spider.py CHANGED
@@ -9,6 +9,8 @@ import requests
9
  from bs4 import BeautifulSoup
10
  from tqdm import tqdm
11
 
 
 
12
 
13
  pattern_without_rating = r"""
14
  name":"(.*)","image":\[(?:.*)\],"brand":"(.*)","review":"(.*)","description":"(.*)","mpn":"(.*)","color":"(.*)","size":"(.*)","sku":"(.*?)".*,"offers":{"@type":"Offer","availability":"(?:.*)","priceCurrency":"(.*)","price":"(.*)","priceValidUntil":"(.*)","url
@@ -129,7 +131,8 @@ headers = {
129
 
130
  finished_mpn = set()
131
 
132
- output_file = "product.jsonl"
 
133
  with open(output_file, "r", encoding="utf-8") as f:
134
  for row in f:
135
  row = str(row).strip()
@@ -140,7 +143,7 @@ with open(output_file, "r", encoding="utf-8") as f:
140
  print("finished count: {}".format(len(finished_mpn)))
141
 
142
  sleep_time = 1
143
- for mpn in tqdm(range(9156603, 9999999)):
144
  # mpn = random.randint(9000000, 9999999)
145
  if mpn in finished_mpn:
146
  continue
@@ -150,6 +153,7 @@ for mpn in tqdm(range(9156603, 9999999)):
150
  print("url: {}".format(url))
151
 
152
  try:
 
153
  resp = requests.get(url, headers=headers, timeout=2)
154
  except Exception:
155
  print("sleep: {}".format(sleep_time))
 
9
  from bs4 import BeautifulSoup
10
  from tqdm import tqdm
11
 
12
+ from project_settings import project_path
13
+
14
 
15
  pattern_without_rating = r"""
16
  name":"(.*)","image":\[(?:.*)\],"brand":"(.*)","review":"(.*)","description":"(.*)","mpn":"(.*)","color":"(.*)","size":"(.*)","sku":"(.*?)".*,"offers":{"@type":"Offer","availability":"(?:.*)","priceCurrency":"(.*)","price":"(.*)","priceValidUntil":"(.*)","url
 
131
 
132
  finished_mpn = set()
133
 
134
+ output_file = project_path / "data/product.jsonl"
135
+
136
  with open(output_file, "r", encoding="utf-8") as f:
137
  for row in f:
138
  row = str(row).strip()
 
143
  print("finished count: {}".format(len(finished_mpn)))
144
 
145
  sleep_time = 1
146
+ for mpn in tqdm(range(9156615, 9999999)):
147
  # mpn = random.randint(9000000, 9999999)
148
  if mpn in finished_mpn:
149
  continue
 
153
  print("url: {}".format(url))
154
 
155
  try:
156
+ time.sleep(2)
157
  resp = requests.get(url, headers=headers, timeout=2)
158
  except Exception:
159
  print("sleep: {}".format(sleep_time))
project_settings.py CHANGED
@@ -3,18 +3,10 @@
3
  import os
4
  from pathlib import Path
5
 
6
- from toolbox.os.environment import EnvironmentManager
7
-
8
 
9
  project_path = os.path.abspath(os.path.dirname(__file__))
10
  project_path = Path(project_path)
11
 
12
 
13
- environment = EnvironmentManager(
14
- path=os.path.join(project_path, 'dotenv'),
15
- env=os.environ.get('environment', 'dev'),
16
- )
17
-
18
-
19
  if __name__ == '__main__':
20
  pass
 
3
  import os
4
  from pathlib import Path
5
 
 
 
6
 
7
  project_path = os.path.abspath(os.path.dirname(__file__))
8
  project_path = Path(project_path)
9
 
10
 
 
 
 
 
 
 
11
  if __name__ == '__main__':
12
  pass