Script bằng AutoIt giúp lấy bài báo nhanh hơn
Chỉ dành cho các bạn lấy được bài báo, thay cho việc bấm link thông thường...
Mình có một vài script viết bằng AutoIt, thao tác chủ yếu:
- Lấy link doi/ieee/springer/... từ clipboard.
- (Nếu cần) soi trong nội dung file htm tải tạm về %temp% để tìm link download thực.
- Gọi địa chỉ link download thực lên trình duyệt (thường chương trình hỗ trợ download sẽ bắt được link này).
Paper Download Helper
Version 0.1:
- Work with IEEE link.
- Other link types are just opened normally!
Code:
#include <File.au3>
#include <String.au3>
Global $shortscrname = StringReplace(@ScriptName, ".au3", "")
Global $xToolTip = 2 * @DesktopWidth / 5
Global $yToolTip = @DesktopHeight - 80
TraySetToolTip("Paper Downloader: Copy a paper link and press F10")
ToolTip("Paper Downloader: Copy a paper link and press F10", $xToolTip, $yToolTip, $shortscrname, 1, 4)
HotKeySet("{F10}", "LinkOneByOne")
Sleep(2000)
ToolTip("")
While 1
WEnd
Func LinkOneByOne()
$cliptext = ClipGet()
If StringLeft($cliptext, 3) = '10.' Then $cliptext = 'http://dx.doi.org/' & $cliptext
If StringInStr($cliptext, 'http://dx.doi.org/') Then ; such as, $cliptext='http://dx.doi.org/10.1049/el:19910787'
_DownloadFile($cliptext, @TempDir, '_doi.htm')
Local $ar
$ielk = ''
_FileReadToArray(@TempDir & '\_doi.htm', $ar)
If Not @error Then
For $el In $ar
If StringInStr($el, 'ieeexplore.ieee.org') Then
$ielk = $el
$ielk = _StringBetween($ielk, '?arnumber=', '"')
$ielk = $ielk[0]
$ielk = 'http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=' & $ielk
EndIf
Next
EndIf
;~ ConsoleWrite($ielk & @CRLF)
If $ielk <> '' Then
ShellExecute($ielk)
EndIf
FileDelete(@TempDir & '\_doi.htm')
ElseIf StringInStr($cliptext, 'ieeexplore.ieee.org/') Then
;http://ieeexplore.ieee.org/xpl/login.jsp?tp=&arnumber=256484&url=http%3A%2F%2Fieeexplore.ieee.org%2Fxpls%2Fabs_all.jsp%3Farnumber%3D256484
;http://ieeexplore.ieee.org/Xplore/defdeny.jsp?url=http%3A%2F%2Fieeexplore.ieee.org%2Fstamp%2Fstamp.jsp%3Ftp%3D%26arnumber%3D1010664%26userType%3D&denyReason=-131&arnumber=1010664&productsMatched=null&userType=
;http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=1566845&contentType=Conference+Publications
$ielk = ''
$ielk = StringSplit($cliptext, '&')
For $el In $ielk
If StringInStr($el, '?arnumber=') Then
$ielk = StringSplit($el, '?arnumber=', 1)
$ielk = $ielk[2]
$ielk = 'http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=' & $ielk
ExitLoop
ElseIf StringInStr($el, 'arnumber=') Then
$ielk = StringReplace($el, 'arnumber=', '')
$ielk = 'http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=' & $ielk
ExitLoop
EndIf
Next
;~ ConsoleWrite($ielk & @CRLF)
If $ielk <> '' Then;ShellExecute('iexplore.exe', $ielk)
ShellExecute($ielk)
EndIf
ElseIf StringLeft($cliptext, 4) = 'http' Then
ShellExecute($cliptext)
Else
ToolTip("No available link was detected!", $xToolTip, $yToolTip, $shortscrname, 2, 4)
EndIf
Sleep(1200)
ToolTip("")
EndFunc ;==>LinkOneByOne
Func _DownloadFile($URLToDownload, $SavedPath, $FileName)
Local $hDownload = InetGet($URLToDownload, $SavedPath & '\' & $FileName, 1, 1)
Do
Sleep(10)
Until InetGetInfo($hDownload, 2) ;Check if the download is complete.
InetClose($hDownload) ;Close the handle to release resources.
EndFunc ;==>_DownloadFile
File exe tạo được từ script trên:
http://www.mediafire.com/?34x59as3lqho5nv