Extract url from image need help

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
provoquestosito
Posts: 75
Joined: Sat Jan 30, 2010 12:43 am

Extract url from image need help

Post by provoquestosito » Mon May 11, 2015 2:30 pm

Hi

I tried from longtime to extract url from an image but it extract only url image (img src), I need the link in the image (a href)

I tried any type of extraction without success because when i use EXTRACTION

Code: Select all

TAG POS=2 TYPE=IMG ATTR=WIDTH:33&&HEIGHT:33&&SRC:../images/yes_33.png EXTRACT=HREF
Extract only the url of image not the link.

Can you help me please with a simple example

URL

Code: Select all

http://www.vpngate.net/en/
HTML CODE (* because some values can be changed)

Code: Select all

<td class="vg_table_row_1" style="text-align: center;"><a href="do_openvpn.aspx?fqdn=*&ip=*&tcp=*&udp=*&sid=*&hid=*"><img src="../images/yes_33.png" height="33" width="33"><br><b>OpenVPN<br>Config file</b></a><br>TCP: *<br>UDP: *</td>
IMAGE
Image

I use firefox 37.0.1 and imacros 8.9.2

Thanks for help
provoquestosito
Posts: 75
Joined: Sat Jan 30, 2010 12:43 am

Re: Extract url from image need help

Post by provoquestosito » Tue May 12, 2015 3:45 pm

It's possible to extract the url from an image?

Otherwise it's possibile to extract the url from the html source ?

When i record the macro the url do not record in macro code.

I need to extract the url "do_openvpn.aspx" in the code of page

Help me please i added all code.

Thanks
chivracq
Posts: 9194
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract url from image need help

Post by chivracq » Thu May 14, 2015 3:10 pm

provoquestosito wrote:Hi

I tried from longtime to extract url from an image but it extract only url image (img src), I need the link in the image (a href)

I tried any type of extraction without success because when i use EXTRACTION

Code: Select all

TAG POS=2 TYPE=IMG ATTR=WIDTH:33&&HEIGHT:33&&SRC:../images/yes_33.png EXTRACT=HREF
Extract only the url of image not the link.

Can you help me please with a simple example

URL

Code: Select all

http://www.vpngate.net/en/
HTML CODE (* because some values can be changed)

Code: Select all

<td class="vg_table_row_1" style="text-align: center;"><a href="do_openvpn.aspx?fqdn=*&ip=*&tcp=*&udp=*&sid=*&hid=*"><img src="../images/yes_33.png" height="33" width="33"><br><b>OpenVPN<br>Config file</b></a><br>TCP: *<br>UDP: *</td>
IMAGE
Image

I use firefox 37.0.1 and imacros 8.9.2

Thanks for help
provoquestosito wrote:It's possible to extract the url from an image?

Otherwise it's possibile to extract the url from the html source ?

When i record the macro the url do not record in macro code.

I need to extract the url "do_openvpn.aspx" in the code of page

Help me please i added all code.

Thanks
"Help me please i added all code." => Oh yep indeed, that was not the case in your original Post when you opened this Thread and I first had a look at it, because I only answer Threads when FCI is mentioned...

For your Pb, I think you simply need to use 'EXTRACT=HTM' instead of 'EXTRACT=HREF'... then use 'EVAL()' with a few 'split()' to isolate the URL...

EDIT: OK, not correct, I see the Pb, I'm looking into it...:

Code: Select all

VERSION BUILD=8820413 RECORDER=FX
TAB T=1
'URL GOTO=http://www.vpngate.net/en/
TAG POS=2 TYPE=IMG ATTR=SRC:http://www.vpngate.net/images/yes_33.png EXTRACT=HREF
'=> Extracted:
' "http://www.vpngate.net/images/yes_33.png"

TAG POS=2 TYPE=IMG ATTR=SRC:http://www.vpngate.net/images/yes_33.png EXTRACT=HTM
'=> Extracted:
' "<img style="outline: 1px solid blue;" src="../images/yes_33.png" height="33" width="33">"
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 9194
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract url from image need help

Post by chivracq » Thu May 14, 2015 3:36 pm

OK, this one works, I simply use Double Relative Positioning from the Link on/from/to the Image:

Code: Select all

VERSION BUILD=8820413 RECORDER=FX
TAB T=1
SET !EXTRACT_TEST_POPUP NO
URL GOTO=http://www.vpngate.net/en/

'TAG POS=2 TYPE=IMG ATTR=SRC:http://www.vpngate.net/images/yes_33.png EXTRACT=HREF
'=> Extracted:
' "http://www.vpngate.net/images/yes_33.png"

'TAG POS=2 TYPE=IMG ATTR=SRC:http://www.vpngate.net/images/yes_33.png EXTRACT=HTM
'=> Extracted:
' "<img style="outline: 1px solid blue;" src="../images/yes_33.png" height="33" width="33">"

'Using Double Relative Positioning:
'***********************************
TAG POS=2 TYPE=IMG ATTR=SRC:http://www.vpngate.net/images/yes_33.png EXTRACT=TXT
TAG POS=R1 TYPE=A ATTR=* EXTRACT=TXT
SET !EXTRACT NULL
TAG POS=R-1 TYPE=A ATTR=* EXTRACT=HREF
'=> Extracted:
' "http://www.vpngate.net/en/do_openvpn.aspx?fqdn=vpn456138852.opengw.net&ip=126.28.170.248&tcp=1438&udp=1280&sid=1431616278636&hid=1275732"
PROMPT {{!EXTRACT}}
(Tested on iMacros for FF v8.8.2, Pale Moon v24.6.2 (=FF31), Win7-x64.)

This will retrieve:

Code: Select all

"http://www.vpngate.net/en/do_openvpn.aspx?fqdn=vpn456138852.opengw.net&ip=126.28.170.248&tcp=1438&udp=1280&sid=1431616278636&hid=1275732"
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Post Reply