How to copy and paste mp3 hyperlink

I have successfully made a macro that goes to this website : (http://tooxclusive.com/download-mp3/) and opens the first post. Once the post has loaded, I have been able to use the “store” command and some javascript to copy the post title and paste it in another online form. The major challenge I have now is telling Kantu to copy the download link in the post and paste it in my other form.

I have tried this with “storeattribute” but unfortunately the mp3 download link has a varying xpath that is not using an id for every post. I am worried that soon when a new post comes up and my macro will try to copy the download link and fail because the xpath will be different.

I also tried this with “Xclick” but I later realized “Xclick” has no option of storing the link attribute. My macro runs after every 5 minutes mainly to go to that link choose the latest post and copy the post title and copy and paste the download link in the post. Someone help.

the mp3 download link has a varying xpath that is not using an id for every post.

If the default recorded Xpath is not stable, often a good option use the text to find the element. Please see FAQ: How to find a button with a specific text?

In your case, this xpath works: //*[text()[contains(.,'DOWNLOAD MP3')]]

{
  "Name": "containstext",
  "CreationDate": "2019-2-18",
  "Commands": [
    {
      "Command": "open",
      "Target": "http://tooxclusive.com/download-mp3/chucky-p-girls-hustle-ft-vibeman-heinzy/",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "//*[text()[contains(.,'DOWNLOAD MP3')]]",
      "Value": ""
    },
    {
      "Command": "comment",
      "Target": "This was recorded by Kantu //*[@id=\"content\"]/div/div[1]/div[5]/p[6]/a/strong",
      "Value": ""
    }
  ]
}

Thanks for the contribution admin. Now that the unstable Xpath has been found I actually don’t want to click ‘DOWNLOAD MP3’ I need to copy the link attribute and store it to be pasted later in another tab.

store attribute works, but you need to select the parent. The page source code is like this:

<p><a href="http://tooxclusive.com/wp-content/uploads/2019/02/Chucky-P-ft-Vibeman-Heinzy-Girls-Hustle.mp3"><strong>DOWNLOAD MP3 </strong></a></p>

The “strong” tag does not have the URL info. So you need to select the parent with //*[text()[contains(.,'DOWNLOAD MP3')]]/parent::*@href

this macro works:

{
  "Name": "geturl",
  "CreationDate": "2019-2-18",
  "Commands": [
    {
      "Command": "open",
      "Target": "http://tooxclusive.com/download-mp3/chucky-p-girls-hustle-ft-vibeman-heinzy/",
      "Value": ""
    },
    {
      "Command": "storeAttribute",
      "Target": "//*[text()[contains(.,'DOWNLOAD MP3')]]/parent::*@href",
      "Value": "url"
    },
    {
      "Command": "echo",
      "Target": "u=${url}",
      "Value": "green"
    }
  ]
}
2 Likes

It works perfect. But for me to understand it better I decided to get another web page with a different twist. Here : Lost

In that case if I wanted to store the link attribute of ‘Download Song’ , how would the “Target”: of my command look like in this scenario.

This one is much easier, because you can simply use the recorded locator.

So when you record the macro you will get

  • click| link=Download Song

and you change this to

  • storeAttribute | link=Download Song@href

And since this is a relative URL (as you can see in the source code), add the root part to it with storeEval:

  • a = "https://www.howwe.biz/"; a = a + "${u}"; a

Macro:

    {
      "Name": "u",
      "CreationDate": "2019-2-18",
      "Commands": [
        {
          "Command": "open",
          "Target": "https://www.howwe.biz/21100/luyimba-lwomaka/1611/vinka/recent/4157B9.html",
          "Value": ""
        },
        {
          "Command": "storeAttribute",
          "Target": "link=Download Song@href",
          "Value": "u"
        },
        {
          "Command": "storeEval",
          "Target": "a = \"https://www.howwe.biz/\"; a = a + \"${u}\"; a",
          "Value": "u2"
        },
        {
          "Command": "echo",
          "Target": "u=${u}",
          "Value": "blue"
        },
        {
          "Command": "echo",
          "Target": "u2=${u2}",
          "Value": "green"
        }
      ]
    }

Thanks a lot. It works perfect. Is there any material online you can recommend for me to read so that I can understand how to extract attributes from any element on any website.

Thanks in advance.

I have tried this with “storeattribute” but unfortunately the mp3 download link has a varying xpath that is not using an id for every post.

this is exactly what I’m experiencing on my website https://naijaplaylist.com.ng
can someone help out? the suggestions here havent worked out so far…

Explain in detail the work you have to do, adding screenshots and information, thanks