I am a begginer and want to know if I am doing a correct way or not.
I have a few sets of URL lists.
Original URL ( only 1 URL )
and target URLs ( it can be 1~5 URLs )
I am basically copy some content from the Original URL to 1~5 target URL ( pages ).
I have these as a set ( multiple original URL (including targets) ). So I need a loop.
I just created 1 set Macros to store the URLs.
========= My Step ==========
Get the original URL by Google script. ( document.querySelectorAll('.Link_orginal .value')[0].innerText; )
Save to variable: Original_URL
Get each target URL by Google script. ( document.querySelectorAll('.Link_links .value')[0].innerText;
Save to variable : Target_URLs
Repeated 5 times. intLoop and +1
The result looks like this.
I was wondering if these are a correct way to do.
If you have another idea or better one, please let me know.
I am wondering if using variables is correct way or I should use array or json.
I need multiple sets of URLs ( original URL including its target URLs ).
And I will make another loops to run another Macro actions
As you may know, I am a beginner in KM and JS as well. I found there are many features in KM and wants to know if mine is correct.
Thank you for reading and your time.
Additionally, I tried ( tested ) json data and loop.
Set a json data.
and made a loop with for each.
But it doesn't work. for each loop seems to not working.
Can you please have a look and let us know what's the problem?
Thanks,
ccstone
October 29, 2021, 11:52pm
3
Hey @apple_sasi ,
On balance your macro looks fine. I would probably change is the Repeat action to a For Each action with the Lines-In-Collection option:
That saves you from having to explicitly manage the number of iterations.
-Chris
1 Like
ccstone:
For Each action
Thanks Chris.
Yes, it works to get each line.
the result is
"["
"{"
... etc.
But I need to get the json data. Orginal URL and target URLs
And loop multiple times. ( the target url amout )
Thank you anyway
ccstone
October 31, 2021, 12:24am
5
The point was that you don't need to store items as JSON data.
You can use a flat list.
-Chris
1 Like
Hi, Chris
Then how I can get the original URL and also target URLs.
The set (list) of URL needs to get the original URL and target URLs ... and then loop.
Thank you,
I think I got it. :
Set a sample data and added a temp end string "DONE".
Set Loop 0 and when K value is "DONE" and the loop sets 0.
if loop is 0, then it's the original URL and is not, then target URLs.
So far, it works fine.
If you have time, plz have a look and see if I understood correctly.
Thank you for ur time again!!
ccstone
November 2, 2021, 12:21am
8
It looks more or less like what I had in mind, and is much easier in this context than dealing with JSON.
-Chris
1 Like
kcwhat
November 2, 2021, 12:46am
9
Hey Chris,
It's seems @apple_sasi is coming in hot while throwing fast balls. Sheesh!
KC
2 Likes
Learned from @ccstone and others. Thank you all.
2 Likes