| 12345678910111213141516171819202122232425262728293031323334 |
- """Focused discovery for actual dormitory, late-night and flavor experiences."""
- from concurrent.futures import ThreadPoolExecutor, as_completed
- import importlib.util
- import json
- from pathlib import Path
- ROOT=Path(__file__).resolve().parents[1]
- spec=importlib.util.spec_from_file_location('su',ROOT/'scripts/collect-five-topic-supplement.py')
- m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m)
- WORK=ROOT/'work/five-topic-research-20261111'
- m.WORK=WORK;m.PUBLIC=WORK/'sources';m.SEARCH=WORK/'search';m.base.PUBLIC=m.PUBLIC
- JOBS=[('student','宿舍 泡面 体验 site:post.smzdm.com'),
- ('student','夜宵 拌面 试吃 site:post.smzdm.com'),
- ('novelty','冬阴功 方便面 试吃 site:post.smzdm.com'),
- ('novelty','香菜 拌面 试吃 site:post.smzdm.com')]
- def main():
- state={'status':'running','sources':[],'rejected':[]};candidates=[]
- for i,(topic,q) in enumerate(JOBS,110):
- try:candidates.extend(m.search(i,topic,q))
- except Exception as e:
- state['rejected'].append({'query':q,'reason':str(e)})
- if 'VERIFICATION' in str(e):break
- with ThreadPoolExecutor(max_workers=2) as pool:
- tasks={pool.submit(m.collect,r):r for r in candidates}
- for f in as_completed(tasks):
- try:
- r=f.result();r['collectionDirectory']='sources';state['sources'].append(r)
- except Exception as e:state['rejected'].append({'url':tasks[f]['url'],'reason':str(e)})
- m.base.save(WORK/'experience-collection-result.json',state)
- print(json.dumps({'readable':len(state['sources']),'rejected':len(state['rejected'])}),flush=True)
- state.update(status='awaiting-semantic-review',candidates=len(candidates));m.base.save(WORK/'experience-collection-result.json',state)
- if __name__=='__main__':main()
|