Jump to content

auto it open a site and download file


Recommended Posts

This script will help you automatically download the all PDF file without pressing or opening the browser.
Note: Does not support the path need login or to purchase. (on IEEE Xplore)

#include <INet.au3>
#include <String.au3>

Global $SaveDir = @DesktopDir & "\"
Global $URLD = 'http://ieeexplore.ieee.org/xpl/tocresult.jsp?reload=true&isnumber=6690268'
Global $iOverwrite = 0
Local $HTMLSource = StringStripWS(_INetGetSource($URLD), 7)
Local $_Arrayline = StringSplit($HTMLSource, @LF)
For $i = 1 To $_Arrayline[0]
    If StringInStr($_Arrayline[$i], 'PDF file icon') Then
        Local $sPathSavePDFF, $sFileName, $sName, $hSRC, $nLine, $sUrlPDF, $StrTMP0, $StrTMP1, $StrTMP2, $StrTMP3, $StrTMP4 = $_Arrayline[$i]
        $StrTMP2 = _StringBetween($StrTMP4, 'arnumber=', '"><img')
        If IsArray($StrTMP2) Then $sName = $StrTMP2[0]
        $StrTMP1 = _StringBetween($StrTMP4, 'Download or View the PDF:', '" href="')
        If IsArray($StrTMP1) Then $sFileName = StringStripWS(StringReplace(StringReplace(StringRegExpReplace($StrTMP1[0], '[[:^print:]]', "_") & " (" & $sName & ").pdf", '/', "_"), ':', "-"), 7)
        $StrTMP0 = _StringBetween($StrTMP4, '" href="', '"><img class="')
        If IsArray($StrTMP0) Then
            $hSRC = _INetGetSource('http://ieeexplore.ieee.org' & $StrTMP0[0])
            $nLine = StringSplit($hSRC, @LF)
            For $x = 1 To $nLine[0]
                If StringInStr($nLine[$x], '<frame src="http') Then
                    $StrTMP3 = _StringBetween($nLine[$x], '<frame src="', '" frameborder=0 />')
                    If IsArray($StrTMP3) Then $sUrlPDF = $StrTMP3[0]
                EndIf
            Next
        EndIf
        If $sUrlPDF <> "" And $sFileName <> "" Then
            $sPathSavePDFF = StringStripWS($SaveDir & $sFileName, 7)
            If FileExists($sPathSavePDFF) And Not $iOverwrite Then
                ConsoleWrite("- Skip file: " & $sFileName & @CRLF)
                ContinueLoop
            Else
                If FileExists($sPathSavePDFF) Then
                    FileDelete($SaveDir & $sFileName)
                    ConsoleWrite("! Overwrite file: " & $sFileName & @CRLF)
                EndIf
                ConsoleWrite("+ Download file: " & $sFileName & "|" & $sUrlPDF & @CRLF)
                TrayTip("Download file from: " & $sUrlPDF, " Save file to:" & $sPathSavePDFF, 1, 1)
                InetGet($sUrlPDF, $sPathSavePDFF, 8, 1)
            EndIf
        EndIf
    EndIf
Next

 

Sorry I'm a beginner.

Regards,
 

Link to comment
Share on other sites

Or perhaps if you are logged in:

#include <INet.au3>
$i = 0

$filewhole = _INetGetSource("http://ieeexplore.ieee.org/xpl/tocresult.jsp?reload=true&isnumber=6690268", True)

Sleep(3000)

$nOffset = 1

While 1
    $array = StringRegExp($filewhole, '(?i)(?-s)<li aria-describedby="art-abs-title-(0*\d+)', 1, $nOffset)

    If @error = 0 Then
        $nOffset = @extended
    Else
        ExitLoop
    EndIf

    $i = $i + 1
    If $i = 22 Then
        ConsoleWrite('>> http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=' & $array[0] & @CRLF)
        ;InetGet('http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=' & $array[$i], $directory & "\" & $array[$i] * '.pdf')
    Else
        ConsoleWrite('http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=' & $array[0] & @CRLF)
    EndIf
WEnd

 

Edited by Jury
Link to comment
Share on other sites

  • 3 weeks later...

Please do not send the request via private message.
If you need support, please create topics so that everyone can help you.

#include <INet.au3>
#include <String.au3>

Local $URLD = 'http://ieeexplore.ieee.org/xpl/tocresult.jsp?reload=true&isnumber=6690268'
ConsoleWrite("+ Please waiting..." & @CRLF)
Local $HTMLSource = StringStripWS(_INetGetSource($URLD), 7)
Local $sLineHTML = StringSplit($HTMLSource, @LF)
Global $sOUTPUT
For $i = 1 To $sLineHTML[0]
    If StringInStr($sLineHTML[$i], '<span id="art-abs-title-') Then
        Local $vPID, $vTitle, $sDOI, $hSRC, $nLine, $StrTMP
        Local $cLineHTML = $sLineHTML[$i]
        $StrTMP = _StringBetween($cLineHTML, 'art-abs-title-', '">')
        If IsArray($StrTMP) Then $vPID = $StrTMP[0]
        $StrTMP = _StringBetween($cLineHTML, '<span id="art-abs-title-' & $vPID & '">', '</span>')
        If IsArray($StrTMP) Then $vTitle = $StrTMP[0]
        $hSRC = _INetGetSource('http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=' & $vPID)
        $nLine = StringSplit($hSRC, @LF)
        For $x = 1 To $nLine[0]
            If StringInStr($nLine[$x], "<a href='http://dx.doi.org") Then
                $StrTMP = _StringBetween($nLine[$x], ' target="blank">', '</a>')
                If IsArray($StrTMP) Then
                    $sDOI = $StrTMP[0]
                Else
                    $sDOI = "Not Found"
                EndIf
            EndIf
        Next
        ConsoleWrite("! ID:" & $vPID & " - DOI:" & $sDOI & " - " & $vTitle & @CRLF)
        $sOUTPUT &= $vTitle & "ID:" & @CRLF & $vPID & " - DOI:" & $sDOI & @CRLF
    EndIf
Next
MsgBox(0, "Complete: See Console Output!", $sOUTPUT)

 

Regards,
 

Link to comment
Share on other sites

Another way :

$sSource = BinaryToString(InetRead("http://ieeexplore.ieee.org/xpl/tocresult.jsp?reload=true&isnumber=6690268"))
$aLinks = StringRegExp($sSource, '<a aria-label="Download or View the PDF:\h*([^"]+)" href="([^"]+)', 3)

For $i = 0 To UBound($links) - 1 Step 2
   $sPDFName = StringRegExpReplace($links[$i], "[^\w ]", "") & ".pdf"
   InetGet("http://ieeexplore.ieee.org/" &$links[$i + 1], @ScriptDir & "\" & $sPDFName, 1)
Next

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...