cut url youtube + get info same column

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

cut url youtube + get info same column

by pecnet on Tue Sep 19, 2017 3:00 pm

Good evening,

I would have a question ...
I go on my imacros and I manage to recover a lot of information
see this topic (viewtopic.php?f=2&t=27956)

However I can extract the information, I retrieve the complete url of a video youtube

what I would like to do is extract only the ID of the video, I searched on the internet but I understand that it is necessary to do a regex, I understood nothing: s

here is the code imacros

Code: Select all
TAG POS=1 TYPE=IFRAME ATTR=ID:MUTEYOUTUBEVIDEOPLAYER EXTRACT=HREF


here is the url that I extract

https://www.youtube.com/embed/UouwabEZy ... widgetid=1

I need to recover the id that finds between embed / and ?autoplay
Is it possible to extract only the id?

And I also have a second question

I simply retrieve its information via imacros

Code: Select all
'PRODUCT TAG
TAG POS=1 TYPE=A ATTR=CLASS:tags-label EXTRACT=TXT
TAG POS=2 TYPE=A ATTR=CLASS:tags-label EXTRACT=TXT


but I would like to know how I can get its same information in the same colone because I have the information on 2 colone

I would like TAG 1, TAG 2

and no

TAG 1 | TAG 2

on my excel file

Firefox 55.0.3 (64 bits)
imacros 8.9.7
on mac El Capitan os

Thanks again for all
Last edited by pecnet on Tue Sep 19, 2017 9:47 pm, edited 1 time in total.
Firefox 55.0.3 (64 bits)
imacros 8.9.7
on mac El Capitan os
(update: 19/09/17)
pecnet
 
Posts: 36
Joined: Wed Nov 25, 2015 1:35 pm

Re: cut url youtube + get info same colone

by chivracq on Tue Sep 19, 2017 3:54 pm

pecnet wrote:
Code: Select all
Firefox 55.0.3 (64 bits)
imacros 8.9.7
on mac El Capitan os


Good evening,

I would have a question ...
I go on my imacros and I manage to recover a lot of information
see this topic (viewtopic.php?f=2&t=27956)

However I can extract the information, I retrieve the complete url of a video youtube

what I would like to do is extract only the ID of the video, I searched on the internet but I understand that it is necessary to do a regex, I understood nothing: s

here is the code imacros

Code: Select all
TAG POS=1 TYPE=IFRAME ATTR=ID:MUTEYOUTUBEVIDEOPLAYER EXTRACT=HREF


here is the url that I extract

https://www.youtube.com/embed/UouwabEZy ... widgetid=1

I need to recover the id that finds between embed / and ?autoplay
Is it possible to extract only the id?

Hum..., always a bit of a "Challenge" to "decipher" your OP (Opening Post) and to understand what you want, but OK, I think I got it, ah-ah...!

Oh yeah, about that, if you could correct your Thread Title with "column"...?, because nobody is going to search the Forum using "colone" as a Search Keyword, ah-ah...! (And even in French, it's "colonne" and not "colone", too bad...!, I happen to be French, oops...! :oops: )

Well, to isolate the Video_ID, yeah, 'REGEX' would probably do the "Job", but I don't like it either, that's why I use 'split()', exactly-exactly like I did in your previous Thread (the one you referred to) to isolate all 4 Categories... It's exactly the same 'EVAL()' Statement...! You should be able to find it by yourself I would think...

pecnet wrote:And I also have a second question

I simply retrieve its information via imacros

Code: Select all
'PRODUCT TAG
TAG POS=1 TYPE=A ATTR=CLASS:tags-label EXTRACT=TXT
TAG POS=2 TYPE=A ATTR=CLASS:tags-label EXTRACT=TXT


but I would like to know how I can get its same information in the same colone because I have the information on 2 colone

I would like TAG 1, TAG 2

and no

TAG 1 | TAG 2

on my excel file

Firefox 55.0.3 (64 bits)
imacros 8.9.7
on mac El Capitan os

Thanks again for all

OK, that is fairly easy, you simply need to reconstruct the Content of '!EXTRACT' like you want...:
Code: Select all
'PRODUCT TAG
SET !EXTRACT NULL
TAG POS=1 TYPE=A ATTR=CLASS:tags-label EXTRACT=TXT
SET Tags_Labels {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=2 TYPE=A ATTR=CLASS:tags-label EXTRACT=TXT
ADD Tags_Labels ,<SP>{{!EXTRACT}}
SET !EXTRACT {{Tags_Labels}}
PROMPT _[{!EXTRACT}}_

It's actually exactly the same Technique like I used in your previous Thread to reconstruct the Content of '!EXTRACT' and to put your 'Navig_Path' in the Format that you wanted into one single Column...

And if you were doing other Extracts before those 2 (I can't tell as you didn't post your whole Script), you then need to store the Content of '!EXTRACT' in some Temp Var before putting it back into '!EXTRACT' and doing a "ADD !EXTRACT {{Tags_Labels}}" instead of the "SET !EXTRACT {{Tags_Labels}}" in my Example...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: cut url youtube + get info same column

by pecnet on Tue Sep 19, 2017 10:00 pm

Bonjour vous parlé français?
c'est plus facile pour moi :-) car j'utilisais google translate pour m'aidais

J'ai corrigé le titre :-)

1. Ok je regarde le SPLIT du précédent topics
2. ça fonctionne :-)

Merci
Firefox 55.0.3 (64 bits)
imacros 8.9.7
on mac El Capitan os
(update: 19/09/17)
pecnet
 
Posts: 36
Joined: Wed Nov 25, 2015 1:35 pm

Re: cut url youtube + get info same column

by chivracq on Wed Sep 20, 2017 2:45 am

pecnet wrote:Bonjour vous parlé français?
c'est plus facile pour moi :-) car j'utilisais google translate pour m'aidais

J'ai corrigé le titre :-)

1. Ok je regarde le SPLIT du précédent topics
2. ça fonctionne :-)

Merci

Yeah but no-no-no...!, sorry, Forum Language is English (and all Documentation is in English as well), for other Users searching the Forum...
(Otherwise I would have switched to French much earlier myself, I've noticed indeed that you "struggle" a bit with English, oops...)
But tja...!, if you want to "achieve" stg (=something) with iMacros a little bit (and any other Programming Language actually, the Documentation is always in English), you can better learn English a little bit... :idea:

=> Translated:
Title corrected...

1- Checking the 'split()' Statement from previous Thread.
2- It works...!
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: cut url youtube + get info same column

by pecnet on Wed Sep 20, 2017 3:27 am

you say true :)
Thanks again
Firefox 55.0.3 (64 bits)
imacros 8.9.7
on mac El Capitan os
(update: 19/09/17)
pecnet
 
Posts: 36
Joined: Wed Nov 25, 2015 1:35 pm

Re: cut url youtube + get info same column

by chivracq on Wed Sep 20, 2017 5:00 am

pecnet wrote:you say true :)
Thanks again

OK..., and did you find out how your 'EVAL()' with 'split()' must look like, in order to isolate the 'Video_ID' from the extracted URL...?
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: cut url youtube + get info same column

by pecnet on Thu Sep 21, 2017 12:24 am

Hello
I tried this but I think I was wrong
it does not work :roll:

Code: Select all
SET !EXTRACT NULL
TAG POS=1 TYPE=IFRAME ATTR=ID:MUTEYOUTUBEVIDEOPLAYER EXTRACT=HREF

ADD ID_YT_VIDEO
SET ID_YT EVAL("var s='{{!EXTRACT}}'; var n='{{MyLoop}}'; var x,y,z; x=s.split('/embed/'); y=x[n].split('?autoplay'); z=y[0]; z;")
SET ID_VIDEO {{ID_YT}}

'END
ADD !EXTRACT {{ID_VIDEO}}


thank you
Firefox 55.0.3 (64 bits)
imacros 8.9.7
on mac El Capitan os
(update: 19/09/17)
pecnet
 
Posts: 36
Joined: Wed Nov 25, 2015 1:35 pm

Re: cut url youtube + get info same column

by chivracq on Thu Sep 21, 2017 4:15 am

pecnet wrote:Hello
I tried this but I think I was wrong
it does not work :roll:

Code: Select all
SET !EXTRACT NULL
TAG POS=1 TYPE=IFRAME ATTR=ID:MUTEYOUTUBEVIDEOPLAYER EXTRACT=HREF

ADD ID_YT_VIDEO
SET ID_YT EVAL("var s='{{!EXTRACT}}'; var n='{{MyLoop}}'; var x,y,z; x=s.split('/embed/'); y=x[n].split('?autoplay'); z=y[0]; z;")
SET ID_VIDEO {{ID_YT}}

'END
ADD !EXTRACT {{ID_VIDEO}}


thank you

Yep, very close...! 8) , you've correctly identified the 2 "Separators" to use for the 2 'split()''s, but you need to understand that 'split()' returns an 'x[n]' or 'y[n]' Array but you need to specify 'n', starting with Index=0 for the 1st Occurrence, Index=1 for the 2nd Occurrence, etc..., like I had done for the 2 first 'Cat_1' and 'Cat_2' Statements that I had left in my Script, before switching to a Construction where I handled the 'n' from outside the 'EVAL()' with the 'MyLoop' Var to allow for an easy Copy&Paste per Block in case you had more than 4 Categories in your Path.
Now you try to use 'MyLoop' but you haven't defined it...

But honestly, you don't need 'MyLoop' for this Thread, simply hardcode 'n' in "x[n]", you want to keep the 2nd Occurrence of the 'x[n]' 'split()' (after the '/embed/')... => "x[1]".

And your 'y[0]' is already correct, as you want to keep the first Occurrence of the 'split()' on "?autoplay" => before the Separator => 'y[0]'. 8)

And you are using 3 different Names for your Var, this will never work, ah-ah...!, you only need one...!
Or simply use '!VAR1' if you get confused with Var Names...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: cut url youtube + get info same column

by pecnet on Thu Sep 21, 2017 4:40 am

Hi,
I think I have a can included
is this logic what you have advanced

but my code still does not
I have done wrong I think

thanks


Code: Select all
SET !EXTRACT NULL
TAG POS=1 TYPE=IFRAME ATTR=ID:MUTEYOUTUBEVIDEOPLAYER EXTRACT=HREF

SET ID_YT EVAL("var s='{{!EXTRACT}}'; var x,y; x=s.split('/embed/'); y=x[0]; y;")
SET ID_VIDEO {{ID_YT}}

'END
ADD !EXTRACT {{ID_VIDEO}}


edit my code
Firefox 55.0.3 (64 bits)
imacros 8.9.7
on mac El Capitan os
(update: 19/09/17)
pecnet
 
Posts: 36
Joined: Wed Nov 25, 2015 1:35 pm

Re: cut url youtube + get info same column

by chivracq on Thu Sep 21, 2017 4:58 am

pecnet wrote:Hi,
I think I have a can included
is this logic what you have advanced

but my code still does not
I have done wrong I think

thanks


Code: Select all
SET !EXTRACT NULL
TAG POS=1 TYPE=IFRAME ATTR=ID:MUTEYOUTUBEVIDEOPLAYER EXTRACT=HREF

SET ID_YT EVAL("var s='{{!EXTRACT}}'; var x,y; x=s.split('/embed/'); y=x[0]; y;")
SET ID_VIDEO {{ID_YT}}

'END
ADD !EXTRACT {{ID_VIDEO}}


edit my code

Beeeehh no...!, now you've removed the 2nd 'split()'..., but you need it...!
You just needed to replace the "x[n]" in your previous Post with "x[1]" for the 'EVAL()' to work... That's all...!
(Yep, and to remove the Declaration for 'MyLoop', but it doesn't hurt if you leave it, it simply doesn't do anything...)
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: cut url youtube + get info same column

by pecnet on Thu Sep 21, 2017 5:30 am

Hi,

euhh
sorry if I am heavy but I tried the 2 and it does not work

Code: Select all
SET ID_YT EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('/embed/'); y=x[1].split('?autoplay'); z=y[0]; z;")

or
Code: Select all
SET ID_YT EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('/embed/'); y=x[1].split('?autoplay');")


thanks
Firefox 55.0.3 (64 bits)
imacros 8.9.7
on mac El Capitan os
(update: 19/09/17)
pecnet
 
Posts: 36
Joined: Wed Nov 25, 2015 1:35 pm

Re: cut url youtube + get info same column

by chivracq on Thu Sep 21, 2017 5:55 am

pecnet wrote:Hi,

euhh
sorry if I am heavy but I tried the 2 and it does not work

Code: Select all
SET ID_YT EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('/embed/'); y=x[1].split('?autoplay'); z=y[0]; z;")

or
Code: Select all
SET ID_YT EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('/embed/'); y=x[1].split('?autoplay');")


thanks

The 2nd one cannot work, 'y' returns a complete Array...

But the 1st one works fine...:
Code: Select all
VERSION BUILD=8820413 RECORDER=FX
'SET !ERRORIGNORE YES
TAB T=1

SET !EXTRACT https://www.youtube.com/embed/UouwabEZy2E?autoplay=1&controls=1&showinfo=0&modestbranding=1&loop=1&fs=0&cc_load_policy=0&iv_load_policy=3&autohide=0&rel=0&enablejsapi=1&origin=https%3A%2F%2Fwww.bigbuy.eu&widgetid=1

SET ID_YT EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('/embed/'); y=x[1].split('?autoplay'); z=y[0]; z;")

PROMPT EXTRACT:<BR>{{!EXTRACT}}<BR><BR>ID_YT:<SP>_{{ID_YT}}_
PAUSE


=> This returns the correct ID:
Code: Select all
EXTRACT:
https://www.youtube.com/embed/UouwabEZy2E?autoplay=1&controls=1&showinfo=0&modestbranding=1&loop=1&fs=0&cc_load_policy=0&iv_load_policy=3&autohide=0&rel=0&enablejsapi=1&origin=https%3A%2F%2Fwww.bigbuy.eu&widgetid=1

ID_YT: _UouwabEZy2E_
(Tested on iMacros for FF v8.8.2, PM v26.3.3 (=FF47), Win10-x64.)
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: cut url youtube + get info same column

by pecnet on Thu Sep 21, 2017 7:45 am

Hello and thank you again !!!!!

it works,

I have adapted for my final imacros code ...

I have a question with imacros version 8..9.7
when the script does not find anything at all it says # EANF #
and I find it very well

but with the imacros code that I adapted in my script

I have for example 10 url of which 4 have an id youtube and 6 not the system works well however for that there is no id youtube it does not put # EANF # but it takes again youtube id of the last line that has found

id-1
id-2
id-2
id-2
id-2
id-3
..

normally it must be


id-1
id-2
# # EANF
# # EANF
# # EANF
id-3
..

can you tell me if I forget a thing in my code?

Thank you


Code: Select all
VERSION BUILD=8940826 RECORDER=FX
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 20
SET !TIMEOUT_STEP 1
TAB T=1


SET !DATASOURCE /Users/mymac/Desktop/link.csv
SET !DATASOURCE_COLUMNS 1
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}

SET URL_Product {{!COL1}}
URL GOTO={{URL_Product}}


SET !EXTRACT NULL
TAG POS=1 TYPE=SPAN ATTR=ITEMPROP:name EXTRACT=TXT




SET !EXTRACT NULL
TAG POS=1 TYPE=IFRAME ATTR=ID:MUTEYOUTUBEVIDEOPLAYER EXTRACT=HREF
SET ID_YT EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('/embed/'); y=x[1].split('?autoplay'); z=y[0]; z;")
SET YT_ID {{ID_YT}}




SET !EXTRACT {{URL_Product}}
ADD !EXTRACT {{YT_ID}}



SAVEAS TYPE=EXTRACT FOLDER=* FILE=BigBuy_Products_{{!NOW:yyyymmdd}}.csv
Firefox 55.0.3 (64 bits)
imacros 8.9.7
on mac El Capitan os
(update: 19/09/17)
pecnet
 
Posts: 36
Joined: Wed Nov 25, 2015 1:35 pm

Re: cut url youtube + get info same column

by chivracq on Thu Sep 21, 2017 9:29 pm

pecnet wrote:Hello and thank you again !!!!!

it works,

I have adapted for my final imacros code ...

I have a question with imacros version 8..9.7
when the script does not find anything at all it says # EANF #
and I find it very well

but with the imacros code that I adapted in my script

I have for example 10 url of which 4 have an id youtube and 6 not the system works well however for that there is no id youtube it does not put # EANF # but it takes again youtube id of the last line that has found

id-1
id-2
id-2
id-2
id-2
id-3
..

normally it must be

id-1
id-2
# # EANF
# # EANF
# # EANF
id-3
..

can you tell me if I forget a thing in my code?

Thank you

Code: Select all
VERSION BUILD=8940826 RECORDER=FX
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 20
SET !TIMEOUT_STEP 1
TAB T=1

SET !DATASOURCE /Users/mymac/Desktop/link.csv
SET !DATASOURCE_COLUMNS 1
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}

SET URL_Product {{!COL1}}
URL GOTO={{URL_Product}}

SET !EXTRACT NULL
TAG POS=1 TYPE=SPAN ATTR=ITEMPROP:name EXTRACT=TXT

SET !EXTRACT NULL
TAG POS=1 TYPE=IFRAME ATTR=ID:MUTEYOUTUBEVIDEOPLAYER EXTRACT=HREF
SET ID_YT EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('/embed/'); y=x[1].split('?autoplay'); z=y[0]; z;")
SET YT_ID {{ID_YT}}

SET !EXTRACT {{URL_Product}}
ADD !EXTRACT {{YT_ID}}

SAVEAS TYPE=EXTRACT FOLDER=* FILE=BigBuy_Products_{{!NOW:yyyymmdd}}.csv

Well, normal..., "#EANF#" is the Result of some 'EXTRACT=TXT/HREF/etc' that returns "HTML Element not found" ["EANF" = "Extraction [Anchor] Not Found"].

Your 'YT_ID' is the Result of an 'EVAL()' Statement (based on some 'EXTRACT'), then you need to handle the Case of the 'EXTRACT' = "#EANF#" or if anything goes "wrong" in the 'EVAL()' yourself in the 'EVAL()' itself... for it to "spit out" the Result that you want... (You have complete Control on what your 'EVAL()' will return as a Result...)

But hum..., let me think, having a look at your Script, now that it is a bit complete, then I can understand a bit what you want to do...
But..., not normal indeed that you get "id-2" several times, unless "id-2" = "__undefined__" for all of them...
If your "first" 'id-2' was a valid Video_ID and it gets repeated, that means that your consecutive URL's from your DataSource all load the same Page with the same embedded Video... (or don't do anything and the Page remains on the last loaded Page).

=> Dunno :? , post a mini-'.CSV' with a few URL's producing such a Result and I can test a bit... :idea:
(You don't need to upload a "real" '.CSV' File, you can just paste a few URL's directly in a Post, can use ]code[ Meta-Tags for example... It's easier for you, because you otherwise need to zip any File you want attach to a Thread (except Images), and it's easier for me, I don't need to download your Attachment, I can simply check all URL's one by one, or easily recreate a mini-'.CSV' if I prefer..., in case of doubt about the Looping...)

And hum..., stg (= something) a bit useless in your Script is the following:
Code: Select all
SET YT_ID {{ID_YT}}

Your Var was already called 'ID_YT'..., there is no use to give it a different Name... unless you were going to do some further Content-Manipulation on one or the other..., which doesn't seem to be the case...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: cut url youtube + get info same column

by pecnet on Sat Sep 23, 2017 2:36 am

Hello first sorry for my answer a late, I was not present yesterday

here is the .csv file that you can download

https://d.pr/f/6qUwto

Thank you for your help
and wish you a good weekend
Firefox 55.0.3 (64 bits)
imacros 8.9.7
on mac El Capitan os
(update: 19/09/17)
pecnet
 
Posts: 36
Joined: Wed Nov 25, 2015 1:35 pm


Return to General Support & Discussions

Who is online

Users browsing this forum: Bing [Bot] and 7 guests

-->