Solved

Python On Mouseover Save URL/Link

Posted on 2016-11-06
4
30 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
This is great thanks for the help.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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 change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
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)

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now