Solved

Python On Mouseover Save URL/Link

Posted on 2016-11-06
4
91 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
While working, an annoying popup showing below will come and we cannot cancel or close it form the screen. The error message will come again and again.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.

724 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