Solved

Python On Mouseover Save URL/Link

Posted on 2016-11-06
4
63 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

770 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