gpt4 book ai didi

javascript - iMacros javascript 根据条件循环

转载 作者:行者123 更新时间:2023-11-28 08:10:57 25 4
gpt4 key购买 nike

任务是更改代理、打开站点(例如 youtube.com)、检查 Logo 是否存在。如果没有 Logo ,请再次执行此操作(更改代理并打开 youtube.com)。如果 Logo 存在,则在搜索表单中粘贴一些单词。但问题是从“do”到“while”的代码部分无法正常工作。它不会打开网址,只是进入无限循环...

UPD1

我对代码做了一些更改,它可以工作,但问题是它在“宏”代码完成后重置代理。当“macro1”代码正在处理时,不会设置代理地址。

UPD2

我尝试添加“n2”变量,在其中存储“n”值,并在“macro1”中再次设置代理,但“n2”始终采用值“1”。不知道如何让它存储“do while”代码中的值。

var macro;
macro = "CODE:";
//var extracted = iimGetLastExtract();
macro += "SET !ERRORIGNORE YES" + "\n";
macro += "SET !EXTRACT_TEST_POPUP NO" + "\n";
macro += "SET !DATASOURCE c:\\proxy.txt" + "\n";
macro += "SET !DATASOURCE_COLUMNS 1" + "\n";
macro += "SET !LOOP 1" + "\n";
macro += "SET !DATASOURCE_LINE {{n}}" + "\n";
macro += "CLEAR" + "\n";
macro += "PROXY ADDRESS={{!COL1}}" + "\n";
macro += "URL GOTO=https://www.youtube.com/" + "\n";
macro += "TAG POS=1 TYPE=IMG ATTR=ID:logo EXTRACT=HREF" + "\n";

var macro1;
macro1 = "CODE:";
macro1 += "SET !ERRORIGNORE YES" + "\n";
macro1 += "CMDLINE !DATASOURCE c:\\address.txt" + "\n";
macro1 += "SET !DATASOURCE_COLUMNS 1" + "\n";
macro1 += "SET !LOOP 1" + "\n";
macro1 += "SET !DATASOURCE_LINE {{i}}" + "\n";
macro1 += "SET !ERRORIGNORE YES" + "\n";
macro1 += "SET !ERRORCONTINUE YES" + "\n";
macro1 += "TAB T=1" + "\n";
macro1 += "TAG POS=1 TYPE=TD ATTR=ID:gs_tti50 CONTENT={{!COL1}}" + "\n";
macro1 += "SET !DATASOURCE c:\\proxy.txt" + "\n";
macro1 += "SET !DATASOURCE_COLUMNS 1" + "\n";
macro1 += "SET !DATASOURCE_LINE {{n}}" + "\n";
macro1 += "PROXY ADDRESS={{!COL1}}" + "\n";
macro1 += "pause" + "\n";

for (i = 1; i <= 10; i++)
{
var n = 1
do
{
iimSet("n",n)
iimPlay(macro);

var ret = iimGetLastExtract();
if(ret == "https://s.ytimg.com/yts/img/pixel-vfl3z5WfW.gif")
{
break;
}
n++;
} while(true)


iimSet("n",n);
iimPlay(macro1);
}

最佳答案

我重新编写了你的​​代码。对其进行测试并向我们提供反馈。

var macro1;

macro1 = "CODE:";
macro1 += "SET !ERRORIGNORE YES" + "\n";
macro1 += "SET !EXTRACT_TEST_POPUP NO" + "\n";
macro1 += "SET !DATASOURCE c:\\proxy.txt" + "\n";
macro1 += "SET !DATASOURCE_COLUMNS 1" + "\n";
macro1 += "SET !DATASOURCE_LINE {{i}}" + "\n";
macro1 += "CLEAR" + "\n";
macro1 += "PROXY ADDRESS={{!COL1}}" + "\n";
macro1 += "URL GOTO=https://www.youtube.com/" + "\n";
macro1 += "TAG POS=1 TYPE=IMG ATTR=ID:logo EXTRACT=HREF" + "\n";

var macro2;

macro2 = "CODE:";
macro2 += "SET !ERRORIGNORE YES" + "\n";
macro2 += "CMDLINE !DATASOURCE c:\\search_words.txt" + "\n";
macro2 += "SET !DATASOURCE_COLUMNS 1" + "\n";
macro2 += "SET !DATASOURCE_LINE {{i}}" + "\n";
macro2 += "SET !ERRORIGNORE YES" + "\n";
macro2 += "SET !ERRORCONTINUE YES" + "\n";
macro2 += "TAB T=1" + "\n";
macro2 += "TAG POS=1 TYPE=TD ATTR=ID:gs_tti50 CONTENT={{!COL1}}" + "\n";
macro2 += "pause" + "\n";

var limit = prompt("How many loops you want to do.", 10);

limit = parseInt(limit);

var proxy_counter = 1;

for (i = 1; i <= limit; i++) {

//open youtube and extract logo link
iimSet("i", proxy_counter)
iimPlay(macro1);

var extracted = iimGetLastExtract();

//if the logo link is present then fill search box
//if not then go to next loop, change proxy, open yt and start over
if (extracted != "#EANF#") {
iimSet("i", i)
iimPlay(macro2);
} else {
proxy_counter++;
}
}

关于javascript - iMacros javascript 根据条件循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24224376/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com