Solved

Python On Mouseover Save URL/Link

Posted on 2016-11-06
4
70 Views
Last Modified: 2016-11-07
I have a private cms summary page of posts and each post has a unique link.  When I do a source on the post hyperlinks I see the links are not there so they are  being created dynamically.  When you mouseover the links they show in the status bar of the browser.  I need to be able to save the links into a variable so I can use them in another script that I have written already.

I am on Windows 7 and I can do any version of Python.  I have 2.7 and 3.5.2 already.

Because the cms is private I can't give you a link.  It appears to be javascript so what can be done in Python to capture the value of the url/link?  I have firebug & Chrome developer tools if you need any further details.
0
Comment
Question by:sharingsunshine
  • 2
  • 2
4 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 41876437
Once the links are on the page (you see their value on mouse over) run this in your browser debugger console :

var __links = document.getElementsByTagName("a");
for(var i=0;i<__links.length;i++)
    console.log(__links[i].href);

Open in new window


if each link have a class, you can filter them by class.
you should be able to see them doign a right click and choose view source using Chrome
0
 

Author Comment

by:sharingsunshine
ID: 41878020
Is there a way to filter on #editor?  Or, can you do regex in the script?  Here is an actual link that your script pulled out.

https://www.blogger.com/blogger.g?blogID=2213276582068581739#editor/target=post;postID=3109894752048232249;onPublishedMenu=overview;onClosedMenu=overview;postNum=29;src=link

class is used too much in other links causing firebug to reach it's limit.  I tried Chrome's developer console but it isn't as easy to work with as firebug.  Is there a way to output this to a file on the server or desktop?  Then I can use my own tools to cull the list.
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 41878027
what is "#editor" ?

of course we can use a condition/filter

var __links = document.getElementsByTagName("a");
for(var i=0;i<__links.length;i++)
    if(__links[i].SOME_ATTRIBUTE == "SOME_VALUE") console.log(__links[i].href);

Open in new window


Another example using a regex checking if the ID of the link contain "editor" :
var __links = document.getElementsByTagName("a");
for(var i=0;i<__links.length;i++)
    if(/editor/.test(__links[i].id) console.log(__links[i].href);

Open in new window

0
 

Author Closing Comment

by:sharingsunshine
ID: 41878059
This is great thanks for the help.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question