Dude extracting a url.

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.

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.

Dude extracting a url.

by bvss12 on Mon Sep 05, 2016 9:03 am

Hi, sorry for my english. I hope you understand me!. I make a bot extract a url, but i have a problem with the bot, when i go to extract the fragment of url imacros extract all url and i need only the fragment. An example of that:

TAG POS=1 TYPE=CITE ATTR=TXT:www.imdb.com/title/tt0484113/ EXTRACT=TXT


I need only "tt0484113", how i can make that?

Note: that code is random, change for all.

Can someone help me, please? Thanks.

Note 2: I use imacros browser 10 or Firefox the last version.
bvss12
 
Posts: 7
Joined: Mon Sep 05, 2016 8:48 am

Re: Dude extracting a url.

by chivracq on Mon Sep 05, 2016 11:49 am

bvss12 wrote:Hi, sorry for my english. I hope you understand me!. I make a bot extract a url, but i have a problem with the bot, when i go to extract the fragment of url imacros extract all url and i need only the fragment. An example of that:

TAG POS=1 TYPE=CITE ATTR=TXT:www.imdb.com/title/tt0484113/ EXTRACT=TXT


I need only "tt0484113", how i can make that?

Note: that code is random, change for all.

Can someone help me, please? Thanks.

Note 2: I use
Code: Select all
imacros browser 10 or Firefox the last version.

FCIM...! :mrgreen:
=> "Last Version" is always a bit vague, you currently have 3 "Last Versions" for iMacros for FF..., and it won't mean much to anybody reading the Thread in a few weeks/months/years...
=> IM10 + iMacros for FF v9.0.3/v8.9.7...?, FF47/48...?, OS...?

But OK, isolating "tt0484113" from the whole URL can easily be achieved using 'EVAL()' + 'split()' (and that will work for all Browsers..., hum except maybe on CR if your Page got opened in a new Tab as '!URLCURRENT' is a bit buggy on iMacros for CR...), you'll find many Examples on the Forum (+ Wiki even).
There are about a dozen possible Solutions, instead of using 'split()', you could use (a combination of) 'replace(), 'indexOf()', 'substr()', 'substring()', 'match()', etc..., but I find 'split()' the easiest to use...

Good luck, mention/confirm your FCI and post your Final Script to make the Thread useful for other Users..., or if you get stuck, but what you want is fairly easy to do..., by yourself or from searching the Forum, I've already posted several times the Answer...
- (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: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Dude extracting a url.

by bvss12 on Mon Sep 05, 2016 3:14 pm

Hi. Thanks for you help, i make this but don't work...

VERSION BUILD=9030808 RECORDER=FX
TAB T=1
URL GOTO=https://www.google.co.ve/#q=imdb+suicide+squad
TAG POS=1 TYPE=CITE ATTR=TXT:www.imdb.com/title/tt1386697/
SET !VAR1 EVAL("'{{!EXTRACT}}'.replace(/[\\www.imdb.com/title/|/]/g, '');")
SET !CLIPBOARD {{!VAR1}}
URL GOTO=https://www.google.co.ve/
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=q<SP>{{!CLIPBOARD}}

@chivracq
bvss12
 
Posts: 7
Joined: Mon Sep 05, 2016 8:48 am

Re: Dude extracting a url.

by bvss12 on Mon Sep 05, 2016 4:01 pm

VERSION BUILD=9030808 RECORDER=FX
TAB T=1
URL GOTO=https://www.google.co.ve/#q=imdb+suicide+squad
WAIT SECONDS=2
TAG POS=1 TYPE=CITE ATTR=TXT:www.imdb.com/title/tt1386697/ EXTRACT=TXT
SET !VAR1 EVAL("'{{!EXTRACT}}'.replace(/[\\www.imdb.com/title/|/]/g, '');")
SET !CLIPBOARD {{!VAR1}}
URL GOTO=https://www.google.co.ve/
WAIT SECONDS=2
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT={{!VAR1}}

I make this, and solve my problem, but i have a question. when the script copy tt1386697, he copy "/" and i need erase /. howi can erase that?
bvss12
 
Posts: 7
Joined: Mon Sep 05, 2016 8:48 am

Re: Dude extracting a url.

by chivracq on Mon Sep 05, 2016 4:12 pm

bvss12 wrote:Hi. Thanks for you help, i make this but don't work...

Code: Select all
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
URL GOTO=https://www.google.co.ve/#q=imdb+suicide+squad
TAG POS=1 TYPE=CITE ATTR=TXT:www.imdb.com/title/tt1386697/
SET !VAR1 EVAL("'{{!EXTRACT}}'.replace(/[\\www.imdb.com/title/|/]/g, '');")
SET !CLIPBOARD {{!VAR1}}
URL GOTO=https://www.google.co.ve/
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=q<SP>{{!CLIPBOARD}}


@chivracq

OK, so you are on iMacros for FF v9.0.3. You could have mentioned the rest of your FCI like I asked, even if it won't/shouldn't play a role in this Thread, so never mind, I guess it's too complicated...

"but don't work..." is a bit vague, what doesn't work...?

First, your Script as is will not work for sure as you don't even do any EXTRACT, so the Content of '!EXTRACT' is currently empty/null...!

Then you use a Global 'replace()', your 'EVAL()' Statement is maybe correct, but I'm no JavaScript Guru and I'm not too good with Global 'replace()', I would use myself 2 'replace()' Statements, the Syntax is then more simple to understand.
And I told you anyway that the easiest way was using 'split()'...
- (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: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Dude extracting a url.

by chivracq on Mon Sep 05, 2016 4:17 pm

bvss12 wrote:
Code: Select all
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
URL GOTO=https://www.google.co.ve/#q=imdb+suicide+squad
WAIT SECONDS=2
TAG POS=1 TYPE=CITE ATTR=TXT:www.imdb.com/title/tt1386697/ EXTRACT=TXT
SET !VAR1 EVAL("'{{!EXTRACT}}'.replace(/[\\www.imdb.com/title/|/]/g, '');")
SET !CLIPBOARD {{!VAR1}}
URL GOTO=https://www.google.co.ve/
WAIT SECONDS=2
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT={{!VAR1}}


I make this, and solve my problem, but i have a question. when the script copy tt1386697, he copy "/" and i need erase /. howi can erase that?

Ah...!, OK, you've found out by yourself the missing "EXTRACT", good...

To remove the 2 "/", simply use another Global 'replace()', the "/" maybe needs to be escaped.
Or you can still use 'split()', but that was already the most easiest and straightforward way...
- (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: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Dude extracting a url.

by bvss12 on Tue Sep 06, 2016 6:29 am

Thanks for all men! Can you give me an example of how use split()?
bvss12
 
Posts: 7
Joined: Mon Sep 05, 2016 8:48 am

Re: Dude extracting a url.

by bvss12 on Tue Sep 06, 2016 6:33 am

I try to make this but not work

VERSION BUILD=9030808 RECORDER=FX
TAB T=1
URL GOTO=https://www.google.co.ve/#q=imdb+suicide+squad
WAIT SECONDS=2
TAG POS=1 TYPE=CITE ATTR=TXT:www.imdb.com/title/tt1386697/ EXTRACT=TXT
SET !VAR1 EVAL("var s=\"{{!EXTRACT}}\"; s.replace(\"www.www.imdb.com/title\",\"\");")
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; s.replace(\"/\",\"\");")
URL GOTO=https://www.google.co.ve/
WAIT SECONDS=2
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT={{!VAR2}}
bvss12
 
Posts: 7
Joined: Mon Sep 05, 2016 8:48 am

Re: Dude extracting a url.

by bvss12 on Tue Sep 06, 2016 6:46 am

Or how can i implement the global .replace()?
bvss12
 
Posts: 7
Joined: Mon Sep 05, 2016 8:48 am

Re: Dude extracting a url.

by chivracq on Tue Sep 06, 2016 8:02 am

bvss12 wrote:Thanks for all men! Can you give me an example of how use split()?

I've already posted many Examples, the Forum is meant as a Search Tool as well...

bvss12 wrote:I try to make this but not work

Code: Select all
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
URL GOTO=https://www.google.co.ve/#q=imdb+suicide+squad
WAIT SECONDS=2
TAG POS=1 TYPE=CITE ATTR=TXT:www.imdb.com/title/tt1386697/ EXTRACT=TXT
SET !VAR1 EVAL("var s=\"{{!EXTRACT}}\"; s.replace(\"www.www.imdb.com/title\",\"\");")
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; s.replace(\"/\",\"\");")
URL GOTO=https://www.google.co.ve/
WAIT SECONDS=2
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT={{!VAR2}}


bvss12 wrote:Or how can i implement the global .replace()?

Dunno, I don't do Global 'replace()', I find the Syntax too complicated, that's why I use 'split()'...
- (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: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Dude extracting a url.

by bvss12 on Tue Sep 06, 2016 8:18 am

And how can i implement split in my macros? Sorry for ask D:
bvss12
 
Posts: 7
Joined: Mon Sep 05, 2016 8:48 am

Re: Dude extracting a url.

by chivracq on Tue Sep 06, 2016 8:55 am

bvss12 wrote:And how can i implement split in my macros? Sorry for ask D:

Read my previous Post again, I gave you a Link to a Search Query on the Forum and the first Hit (passed your own Thread) already contains some working Example...! :roll:
- (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: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to Data Extraction and Web Screen Scraping

Who is online

Users browsing this forum: No registered users and 3 guests

-->