click the first link based on search result from CSV

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.

click the first link based on search result from CSV

by papichan on Sat Apr 30, 2016 8:52 am

I need to click a link that isn't based on the text value of that link, so what ever the link will be on each iteration. I have looked at xpath but obviously the value will change each time. Any pointers would be gratefully received.

Code: Select all
VERSION BUILD=10022823
TAB T=1
TAB CLOSEALLOTHERS
SET !DATASOURCE C:\Users\Tom\Desktop\EANF.csv
SET !LOOP 2
SET !DATASOURCE_LINE {{!LOOP}}
URL GOTO=https://www.endole.co.uk/company/
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/search/ ATTR=NAME:search CONTENT={{!COL1}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:/search/ ATTR=CLASS:search_button

TAG POS=1 TYPE=A ATTR=TXT:Infosys<SP>Limited
<!-- This needs to be defined as relating to the result from the CSV -->

TAG POS=10 TYPE=LI ATTR=CLASS:overview_bullet EXTRACT=TXT
TAG POS=11 TYPE=LI ATTR=CLASS:overview_bullet EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\Tom\Desktop FILE=C:\Users\Tom\Desktop\EANFWrite.csv
papichan
 
Posts: 8
Joined: Sat Apr 30, 2016 8:28 am

Re: click the first link based on search result from CSV

by chivracq on Sat Apr 30, 2016 10:02 am

papichan wrote:I need to click a link that isn't based on the text value of that link, so what ever the link will be on each iteration. I have looked at xpath but obviously the value will change each time. Any pointers would be gratefully received.

Code: Select all
VERSION BUILD=10022823
TAB T=1
TAB CLOSEALLOTHERS
SET !DATASOURCE C:\Users\Tom\Desktop\EANF.csv
SET !LOOP 2
SET !DATASOURCE_LINE {{!LOOP}}
URL GOTO=https://www.endole.co.uk/company/
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/search/ ATTR=NAME:search CONTENT={{!COL1}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:/search/ ATTR=CLASS:search_button

TAG POS=1 TYPE=A ATTR=TXT:Infosys<SP>Limited
<!-- This needs to be defined as relating to the result from the CSV -->

TAG POS=10 TYPE=LI ATTR=CLASS:overview_bullet EXTRACT=TXT
TAG POS=11 TYPE=LI ATTR=CLASS:overview_bullet EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\Tom\Desktop FILE=C:\Users\Tom\Desktop\EANFWrite.csv

Simply use Wildcards (*), you may then have to adjust POS=1 to POS=2/3/4/5/etc..., eventually combined with Relative Positioning...
- (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: 6475
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: click the first link based on search result from CSV

by papichan on Sat Apr 30, 2016 10:41 am

Hi Thanks for your help, I tried the below, with and without relative position and it just goes back to the initial url after line 11; do you think it is the page, or the code?
Code: Select all
VERSION BUILD=10022823
TAB T=1
TAB CLOSEALLOTHERS
SET !DATASOURCE C:\File
SET !LOOP 2
SET !DATASOURCE_LINE {{!LOOP}}
URL GOTO=https://www.endole.co.uk/
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/search/ ATTR=NAME:search CONTENT={{!COL1}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:/search/ ATTR=CLASS:searchbox_button
WAIT SECONDS=2
TAG POS=R1 TYPE=A ATTR=TXT:*
TAG POS=10 TYPE=LI ATTR=CLASS:overview_bullet EXTRACT=TXT
TAG POS=11 TYPE=LI ATTR=CLASS:overview_bullet EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\Tom\Desktop\Code FILE=C:\File
papichan
 
Posts: 8
Joined: Sat Apr 30, 2016 8:28 am

Re: click the first link based on search result from CSV

by chivracq on Sat Apr 30, 2016 9:09 pm

papichan wrote:Hi Thanks for your help, I tried the below, with and without relative position and it just goes back to the initial url after line 11; do you think it is the page, or the code?
Code: Select all
VERSION BUILD=10022823
TAB T=1
TAB CLOSEALLOTHERS
SET !DATASOURCE C:\File
SET !LOOP 2
SET !DATASOURCE_LINE {{!LOOP}}
URL GOTO=https://www.endole.co.uk/
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/search/ ATTR=NAME:search CONTENT={{!COL1}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:/search/ ATTR=CLASS:searchbox_button
WAIT SECONDS=2
TAG POS=R1 TYPE=A ATTR=TXT:*
TAG POS=10 TYPE=LI ATTR=CLASS:overview_bullet EXTRACT=TXT
TAG POS=11 TYPE=LI ATTR=CLASS:overview_bullet EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\Tom\Desktop\Code FILE=C:\File

Dunno, provide a few valid Data Samples for '!COL1' from your '.CSV' for any Testing... :roll:

And if you could mention your FCI (read my Sig...), that could be useful as well... :idea:
- (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: 6475
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: click the first link based on search result from CSV

by papichan on Sat May 14, 2016 9:22 am

My work around solution was to use wildcards and a HREF

Code: Select all
TAG POS=1 TYPE=A ATTR=HREF:*/company/*


So that it opened the first link with this structure; in this case it works but realise it isn't the best solution
papichan
 
Posts: 8
Joined: Sat Apr 30, 2016 8:28 am

Re: click the first link based on search result from CSV

by chivracq on Sat May 14, 2016 10:49 am

papichan wrote:My work around solution was to use wildcards and a HREF

Code: Select all
TAG POS=1 TYPE=A ATTR=HREF:*/company/*


So that it opened the first link with this structure; in this case it works but realise it isn't the best solution

Okay..., good-good-good, Thanks for the Follow-up/sharing your "Solution", even if I had to ask a bit for it, huhum...!, and FCI is still missing, OK, I can copy it from your 2nd Thread, but, pff, it's not really my "Role" to go fishing and play the "Detective" around your different Threads, and your exact Config could definitely play a Role in this Thread as it might dictate which Modes are available to use...

FCI:
Code: Select all
IMB v10.0.2.2823
Win7 64


Well, about your "Solution not being the best Solution...", dunno again, explain why...?, or is it related to your 2nd Thread...?, and you don't provide a few '!COL1' Values like I asked you, I'm not going to try to guess those, you need to provide (proactively actually, I shouldn't need to ask, and even less several times...) all Info that can be useful to fully be able to understand what you want with your Script and to be able to reproduce and do any "Concrete" Testing, I lose "Interest" in a Case/Thread if I have to ask several times for the same things..., otherwise I could probably find a better Solution than the one you went for...
- (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: 6475
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 2 guests

-->