?
Solved

Python On Mouseover Save URL/Link

Posted on 2016-11-06
4
Medium Priority
?
107 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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
A quick guide on how to use Group Policy to create a custom power plan and set it active on Windows 7.
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

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