222
This commit is contained in:
parent
0a2e896962
commit
2788e2db2a
@ -41,6 +41,7 @@ import java.io.InputStream;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 亚马逊爬虫控制器 - 爬取价格和卖家信息
|
* 亚马逊爬虫控制器 - 爬取价格和卖家信息
|
||||||
@ -98,7 +99,7 @@ public class WebMagicController extends BaseController implements PageProcessor
|
|||||||
private void loadProxyConfig() {
|
private void loadProxyConfig() {
|
||||||
try {
|
try {
|
||||||
//File configFile = ResourceUtils.getFile("classpath:test_proxy.yml");
|
//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()) {
|
if (configFile.exists()) {
|
||||||
Yaml yaml = new Yaml();
|
Yaml yaml = new Yaml();
|
||||||
try (InputStream inputStream = new FileInputStream(configFile)) {
|
try (InputStream inputStream = new FileInputStream(configFile)) {
|
||||||
@ -168,7 +169,6 @@ public class WebMagicController extends BaseController implements PageProcessor
|
|||||||
@Override
|
@Override
|
||||||
public void process(Page page) {
|
public void process(Page page) {
|
||||||
try {
|
try {
|
||||||
System.out.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
|
|
||||||
Html html = page.getHtml();
|
Html html = page.getHtml();
|
||||||
String priceSymbol = html.xpath("//span[@class='a-price-symbol']/text()").toString();
|
String priceSymbol = html.xpath("//span[@class='a-price-symbol']/text()").toString();
|
||||||
String priceWhole = html.xpath("//span[@class='a-price-whole']/text()").toString();
|
String priceWhole = html.xpath("//span[@class='a-price-whole']/text()").toString();
|
||||||
@ -311,10 +311,9 @@ public class WebMagicController extends BaseController implements PageProcessor
|
|||||||
try {
|
try {
|
||||||
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))
|
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))
|
||||||
.get(3, TimeUnit.SECONDS);
|
.get(3, TimeUnit.SECONDS);
|
||||||
} catch (Exception e) {
|
} catch (TimeoutException te) {
|
||||||
logger.debug("等待代理测试完成时发生异常", e);
|
logger.debug("等待代理测试完成超时,这是正常现象");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CompletableFuture<Map<String, Object>> future : futures) {
|
for (CompletableFuture<Map<String, Object>> future : futures) {
|
||||||
try {
|
try {
|
||||||
if (future.isDone() && !future.isCompletedExceptionally()) {
|
if (future.isDone() && !future.isCompletedExceptionally()) {
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
class="action-button"
|
class="action-button"
|
||||||
>开始爬取</el-button>
|
>开始爬取</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<!-- <el-col :span="3">
|
<el-col :span="3">
|
||||||
<el-button
|
<el-button
|
||||||
type="info"
|
type="info"
|
||||||
plain
|
plain
|
||||||
@ -49,7 +49,7 @@
|
|||||||
@click="openProxyDialog"
|
@click="openProxyDialog"
|
||||||
class="action-button"
|
class="action-button"
|
||||||
>选择代理</el-button>
|
>选择代理</el-button>
|
||||||
</el-col>-->
|
</el-col>
|
||||||
<el-col :span="15">
|
<el-col :span="15">
|
||||||
<div class="notice-box" v-if="asinList.length > 0">
|
<div class="notice-box" v-if="asinList.length > 0">
|
||||||
已导入 <span class="count-number">{{asinList.length}}</span> 个ASIN
|
已导入 <span class="count-number">{{asinList.length}}</span> 个ASIN
|
||||||
@ -724,7 +724,7 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.startProxyTest(); // 直接开始测试,不弹确认框
|
this.startProxyTest();
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 开始测试代理节点 */
|
/** 开始测试代理节点 */
|
||||||
@ -788,6 +788,8 @@ export default {
|
|||||||
proxyNode.testing = false;
|
proxyNode.testing = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.saveProxyDelaysToCache();
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 处理测试错误 */
|
/** 处理测试错误 */
|
||||||
@ -804,6 +806,8 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.$message.warning('部分代理测试失败,继续测试下一批');
|
this.$message.warning('部分代理测试失败,继续测试下一批');
|
||||||
|
// 保存当前已测试的延迟数据
|
||||||
|
this.saveProxyDelaysToCache();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.testNextBatch(batches, batchIndex + 1);
|
this.testNextBatch(batches, batchIndex + 1);
|
||||||
}, 500);
|
}, 500);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user