Jump to content
Macro Express Forums

Keep/remove text chains.


Recommended Posts

Hello,

In order to download a lot of images for a personnal project, I'm looking for a way, from the source code of this kind of link :

https://www.dreamstime.com/search.php?securitycheck=1ca077d0e2dd106ec49a55a750695398&srh_field=chicken&firstvalue=enter+keyword+or+file+ID&lastsearchvalue=&s_catid=0&s_cliid=2503490&s_colid=&s_ph=y&s_video=y&s_audio=y&s_il=y

To keep only the links of the thumbs, for exemple for the chicken :

https://thumbs.dreamstime.com/t/full-body-brown-chicken-hen-standing-isolated-white-backgroun-background-use-farm-animals-livestock-theme-49741285.jpg

 The kind of code to remove arround the links :

<img class="bigthumb showonload" id="bigthumb49741285" src="https://thumbs.dreamstime.com/t/full-body-brown-chicken-hen-standing-isolated-white-backgroun-background-use-farm-animals-livestock-theme-49741285.jpg" alt="Full body of brown chicken hen standing isolated white backgroun Royalty Free Stock Photo" style="height: 158px; width: 162px; margin-top: 0px; visibility: visible;">

Then I want to replace the  /t/ on the link by /z/

Can someone help me please ?

Link to comment
Share on other sites

Get all the source code into a Macro Express text variable.  It looks like you can find the links you want by searching for the /t/ string.  You can do that with command Variable Set Integer [Get Position of Text in a Text Variable].

Once you have the integer index pointing to /t/ within the source code, you can back up one character at a time looking for https: (the beginning of the link).  That is, use a Repeat loop to decrement the index integer by one, copy 6 characters to another variable using command Variable Modify String [Copy Part of Text], and check whether the copied text is https:  Exit from the Repeat loop when the match is found.

At this point your integer (index) points to the beginning of the link.  Find the end of the link with a similar Repeat loop incrementing the index until you find the double-quote.  Now you know the beginning and ending positions of the link text, and you can use Variable Modify String [Copy Part of Text] to copy the whole link text to another variable, save it in a text file, or whatever.  Use Variable Modify String [Replace Substring] to change /t/ to /z/.

Use Variable Modify String [Delete Part of Text] to delete everything from the beginning of the source code to the end of the link you just extracted.  Then repeat all the logic above to extract the next link, and so on until done. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...