222
This commit is contained in:
parent
2788e2db2a
commit
72b94a22b0
@ -274,8 +274,7 @@ public class BanmaOrderController extends BaseController {
|
||||
|
||||
Thread thread = new Thread(() -> {
|
||||
try {
|
||||
int size = 20;
|
||||
// 若已超时或已完成则不处理
|
||||
int size = 20;
|
||||
if (deferredResult.isSetOrExpired()) return;
|
||||
|
||||
R<List<Map<String, Object>>> pageResult = getOrders(page, size);
|
||||
|
@ -99,7 +99,7 @@ public class WebMagicController extends BaseController implements PageProcessor
|
||||
private void loadProxyConfig() {
|
||||
try {
|
||||
//File configFile = ResourceUtils.getFile("classpath:test_proxy.yml");
|
||||
File configFile = new File("/www/java_mall/erp/config/test_proxy.yml");
|
||||
File configFile = new File("/www/java_mall/erp/config/test_proxy.yml");
|
||||
if (configFile.exists()) {
|
||||
Yaml yaml = new Yaml();
|
||||
try (InputStream inputStream = new FileInputStream(configFile)) {
|
||||
@ -176,10 +176,8 @@ public class WebMagicController extends BaseController implements PageProcessor
|
||||
if (priceSymbol != null && !priceSymbol.isEmpty() && priceWhole != null && !priceWhole.isEmpty()) {
|
||||
resultMap.put("price", priceSymbol + priceWhole);
|
||||
}
|
||||
|
||||
resultMap.put("seller", html.xpath("//a[@id='sellerProfileTriggerId']/text()").toString());
|
||||
resultMap.put("asin", html.xpath("//input[@id='ASIN']/@value").toString());
|
||||
|
||||
String price = (String) resultMap.get("price");
|
||||
String seller = (String) resultMap.get("seller");
|
||||
Object retriesObj = page.getRequest().getExtra("retries");
|
||||
@ -268,12 +266,25 @@ public class WebMagicController extends BaseController implements PageProcessor
|
||||
.setDownloader(getProxyDownloader())
|
||||
.thread(1);
|
||||
spider.run();
|
||||
String price = (String) resultMap.get("price");
|
||||
String resultAsin = (String) resultMap.get("asin");
|
||||
if ((resultAsin == null || resultAsin.isEmpty() || price == null || price.isEmpty())) {
|
||||
Thread.sleep(1000 + random.nextInt(2000));
|
||||
logger.info("ASIN:{} 的价格或ASIN为空,进行一次重试", asin);
|
||||
|
||||
resultMap = new HashMap<>();
|
||||
resultMap.put("asin", asin);
|
||||
|
||||
spider = Spider.create(this)
|
||||
.addUrl(url)
|
||||
.setDownloader(getProxyDownloader())
|
||||
.thread(1);
|
||||
spider.run();
|
||||
}
|
||||
} finally {
|
||||
clearSystemProxy();
|
||||
}
|
||||
|
||||
resultList.add(new HashMap<>(resultMap));
|
||||
|
||||
}
|
||||
deferredResult.setResult(ResponseEntity.ok(R.ok(resultList)));
|
||||
} catch (Exception e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user