var serial = ["552861802186","732146914443"]
var URL = ["https://www.justdial.com/Ahmedabad/New-Shobhana-Embroidery-Opposite-Konark-Karishma-Flats-Vastrapur/079PXX79-XX79-110316110340-F9T3_BZDET?xid=QWhtZWRhYmFkIFNhcmVlIFJldGFpbGVycw==",
"https://www.justdial.com/Ahmedabad/Sukanya-Opposite-Navneet-Gala-Gurukul/079PXX79-XX79-140406171027-T1C6_BZDET?xid=QWhtZWRhYmFkIFNhcmVlIFJldGFpbGVycw=="]
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until;
var driver = new webdriver.Builder().forBrowser('firefox').build();
for(var i = 0; i <= 2; i++){
driver.get(URL[i]);
driver.wait(function () {
driver.executeScript('return document.readyState').then(function(return_value) {
driver.executeScript("var phone = [{ 'Name': $('.fn').text(), 'Phone': [] }]; $('ul.comp-contact > span.telnowpr > a.tel').each(function(index, el) { phone[0].Phone.push($(this).html()) }); return phone;").then(function(return_value) {
console.log(return_value);
}, function (err) {})
}, function (err) {})
}, 1);
}
有两个主要问题
(1)在控制台中多次打印返回值。
(2)它没有从第一个URL返回值。它仅从 第二个网址。我该如何解决所有这些问题?