• Intro to AutoHotkey HotStrings with AutoHotkey Intermediate AutoHotkey GUIs are Easy with AutoHotkey Intro to DOS & AutoHotkey

Rip the URL from the Clipboard with AutoHotkey

Someone asked me if I had a tool that would look at the clipboard and return only the URL or Rip the  URL from the Clipboard. (The clipboard has various formats like: Files, Text, Rich Text Format, HTML, Images, etc.).

I used the cool WinClip library which can be grabbed here: https://autohotkey.com/board/topic/74670-class-winclip-direct-clipboard-manipulations/ and, with the help of maestrith, wrote a script which returns the various items on the clipboard in HTML format as an object.

Rip the URL from the Clipboard

 
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance,Force
SetBatchLines,-1
global Com:=ComObjCreate(“HTMLFile”)
;*******************************************************
Browser_Back:: ;Change this hotkey to what you want
CB:=ClipboardAll
Clipboard:=””
while(Clipboard){
Sleep,10
}
Send,^c
while(!Clipboard){
Sleep,10
}
Clip:=Get_Clipboard_Data() ;Call the function and return the HTML data in an object
MsgBox % clip.1.HREF
DebugWindow(Obj2String(Clip),1,1,200,0)
Clipboard:=CB ;restore Clipboard
return

;********************Grab data from Clipboard***********************************
Get_Clipboard_Data(){
wc := new WinClip
wc.iSnap()
Obj:=[]
try:=wc.iGetHTML()
HTML:=SubStr(Try,InStr(Try,”<HTML>”))
Com.Close()
Com.Write(HTML)
All:=Com.GetElementsByTagName(“a”)
Url:=[]
RegExMatch(Try,”OUi)SourceURL:(.*)\R”,Found)
while(aa:=All.Item[A_Index-1]){
URL.Push({Page:Found.1,Text:aa.InnerText,HREF:aa.HREF})
}
return URL
}
;~ https://autohotkey.com/board/topic/74670-class-winclip-direct-clipboard-manipulations/
#Include B:\Progs\AutoHotkey_L\AHK Work\WinClip\WinClipAPI.ahk
#Include B:\Progs\AutoHotkey_L\AHK Work\WinClip\WinClip.ahk

Automate Unicode character encoding for HTML

Unicode character encoding

AutoHotkey Bottle 1Our CMS does not support Unicode text thus when we need to search-replace for characters like the and © symbols. This takes a fair amount of time and is easy to miss so I wrote a script in AutoHotKey to automatically handle the Unicode character encoding.

Now I can highlight the word and click a button and  Whamo!  Instant replacement with HTML equivalents!  No more trying to scan text and find illegal characters.

Black Bottle 2Unicode character encoding

Here is the AutoHotKey code I use.  My code first grabs the highlighted text and copies it to the clipboard, where it manipulates it, then sends it back to the active program I was working in. No more need for Unicode character encoding!

Web Scraping with AutoHotKey 106- Web Scraping multiple pages

Web Scraping multiple pages

AutoHotkey Bottle 1 Web Scraping multiple pages

Example of how to Web Scraping multiple pages with some simple URL manipulation.  This is where being able to make sure you’ve loaded a page fully, scrape it, then navigate to the next is critical.  Looking for patterns in the URL will help you understand how you’ll be able to navigate to the next page.

A copy of the AutoHotKey syntax writer can be found here.  Remember patience is a virtue and Happy Scraping!

AutoHotkey Bottle 4

How to Web Scrape with AutoHotkey: Setting values and clicking links in IE

Setting values and clicking links in IE

Setting values and clicking links in IEThis is the second video in this series.  Here we practice setting values and clicking links in IE on a page (kind of reverse of Web Scraping with AutoHotkey however I don’t believe anybody has coined a decent term yet) and clicking links.

Word of warning- some pages want you to fire an “event”.  Sometimes this is tricky.  Given this video is set to an introductory level I only touch a little on the subject.

Web Scraping with AutoHotKey 102-Setting values and clicking links in IE

Setting values and clicking links in IE

The syntax for writing the writing the code can be found on my first post here.  There is also an AutoHotKey forum thread you might wish to review hereSetting values and clicking links in IE is pretty straight forward

Web scraping

 (web harvesting or web data extraction) is a computer software technique of extracting information from websites. Usually, such software programs
  • Intro to AutoHotkey HotStrings with AutoHotkey Intermediate AutoHotkey GUIs are Easy with AutoHotkey Intro to DOS & AutoHotkey