Dent

How to download uniquely generated PDF?

20 posts in this topic

Hi everyone,

My script uses IE11 on Win7 to log in to a site and enters data into a couple of forms. Upon clicking a link this data is used by the site to generate a PDF report.

With my current set-up if I do this manually the PDF opens in a new IE tab and I can download or print it. If I right-click the link that creates the PDF and choose Save Target As the PDF is generated and the Open/Save As dialogue at the bottom of the screen opens. All good.

However I would like the script to automatically download the PDF and close IE and then exit. Closing IE (_IEQuit) and exiting the script are easy enough, but I'm struggling getting the script to download the PDF.

The link to generate the PDF contains a unique number each time the page with the link is reached, so it's not static. The link position however, using _IELinkGetCollection I can tell the link to generate the PDF is always the 10th one from the end of the page, so using $iNumLinks - 10 I am able to click the link.

What I believe I need to use is InetGet however the problem I've been facing is that the link isn't static and I haven't worked out a way to access the link by index - is this possible?

Here is the website HTML for the section containing the link although I don't think it's of much use but it at least shows the format of the link (I can't post a link as it's a password protected area)...

<div class="rmButton right"><a title="Generates a PDF version of the market report in a new window." href="/rmplus/generatePdf?mr_id=60991" target="_blank">print/save as pdf</a></div>

The full link https://www.rightmove.co.uk/rmplus/generatePdf?mr_id=60991 just for completeness - visiting it will give a HTTP 500 unless logged in.

And here is the code that clicks this link opening the generated PDF in a new tab...

$oLinks = _IELinkGetCollection($oIE)
$iNumLinks = @extended
$PrintPDF = _IELinkClickByIndex($oIE, ($iNumLinks - 10))

So, how to use InetGet to visit that link? Or is there a way to Save As the newly opened tab? I've tried _IEAction($oIE, "saveas") but it seems not to work in a tab containing only a PDF.

Share this post


Link to post
Share on other sites



7 minutes ago, Dent said:

The full link https://www.rightmove.co.uk/rmplus/generatePdf?mr_id=60991 just for completeness - visiting it will give a HTTP 500 unless logged in.

 

This is what I get when I click this link:

Quote

Sorry

Sorry there is a problem

Reference No #2301-161111-100642-10401

 


February 26, 2017: New SciTE4AutoIt3 available with the updated SciTE v3.7.3 release
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2017-02-26
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

Two ways (first method is easier):

- download all the page content with _IEBodyReadHTML and retrieve your mr_id through regular expressions (StringRegExp)

- use .getattribute method to retrieve href attribute in the div with "Generates a PDF version of the market report in a new window." a title attribute.

Then you can build full link and use InetGet to download the file.

Share this post


Link to post
Share on other sites

HREF is not pointing directly to PDF file , so I'm not sure if InetGet will work.

 


February 26, 2017: New SciTE4AutoIt3 available with the updated SciTE v3.7.3 release
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2017-02-26
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

Thank-you both for your input.

j0kky, I was really hoping your first method would work - I don't know why I didn't think of this, but I have a habit of coding whilst tired.

So I used StringInStr and StringMid etc to obtain the actual link, here's the code...

$Page = _IEBodyReadHTML($oIE)
$PrintPDFStart = StringInStr($Page, "?mr_id=")
$PrintPDFEnd = StringMid($Page, $PrintPDFStart, 12)
$PrintPDF = ("https://www.rightmove.co.uk/rmplus/generatePdf" & $PrintPDFEnd)
$hDownload = InetGet($PrintPDF, @ScriptDir & "\Report.pdf")
Do
    Sleep(250)
Until InetGetInfo($hDownload, 2)
InetClose($hDownload)

I checked the result of $PrintPDF to be sure the URL is 100% correct, which it is, but unfortunately the script just hangs. mLipok you were right :(

I haven't tried your second method as I also don't see this working as I think the problem is with InetGet()

I think the answer may lie in trying to save the PDF from the newly created IE tab.

Share this post


Link to post
Share on other sites

Q1

In this new tab can you manualy Save this pdf file ? I want to know the file name.

Q2

When this new tab is open , how You close them ?

 

Ps.

Long time ago I had the same problem 

 


February 26, 2017: New SciTE4AutoIt3 available with the updated SciTE v3.7.3 release
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2017-02-26
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

Hi mLipok and thanks for replying again.

Q1. In the new tab which just has the title 'rightmove.co.uk' I can manually save the pdf and the filename is 'generatePDF.pdf' but I haven't been able to save it using AutoIt yet.

Q2. I have only been able to close the tab manually, I have tried _IEAttach to the new tab and then _IEQuit but it doesn't work. I think I would need to interact with the interface by simulating a mouse-click.

Share this post


Link to post
Share on other sites

I think I have solution to Q1.

But I'm not able to find it quickly .

 

1 person likes this

February 26, 2017: New SciTE4AutoIt3 available with the updated SciTE v3.7.3 release
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2017-02-26
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

I think part of the issue is that you didn't indicate that InetGet should download the file in the background. The revised code should look like

$hDownload = InetGet($PrintPDF, @ScriptDir & "\Report.pdf", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
Do
    Sleep(250)
Until InetGetInfo($hDownload, 2)

The other issue that you are likely running into is that the InetGet will fail due to security reasons. In the past, I have resolved this by _IECreateEmbedded within a hidden GUI so that the web browser is running in the same context as the script.

Share this post


Link to post
Share on other sites
8 hours ago, Danp2 said:

I think part of the issue is that you didn't indicate that InetGet should download the file in the background. The revised code should look like

$hDownload = InetGet($PrintPDF, @ScriptDir & "\Report.pdf", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
Do
    Sleep(250)
Until InetGetInfo($hDownload, 2)

The other issue that you are likely running into is that the InetGet will fail due to security reasons. In the past, I have resolved this by _IECreateEmbedded within a hidden GUI so that the web browser is running in the same context as the script.

Thanks Danp2, it could be a context thing, InetGet doesn't return an error it just hangs. I don't think I'll be able to sniff the connection either as it's SSL.

I tried your variation above and the same thing happens. InetRead at least does return that 0 bytes have been read so I guess it is getting blocked.

Maybe using IUAutomation is the way and actually controlling the new tab that is created when the link is clicked - but I've never used that UDF.

Share this post


Link to post
Share on other sites
10 hours ago, mLipok said:

I think I have solution to Q1.

But I'm not able to find it quickly .

 

Something like this:

_Example()
Func _Example()
    Local $sIECacheDir = _IE_GetCacheDir()
    Local $aKatalogi = _FileListToArrayRec($sIECacheDir, 'generatePDF*.pdf', 1, 1, 0, 2)
EndFunc


Func _IE_GetCacheDir()
    Local $sIECacheDir = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\', 'Cache')
    $sIECacheDir = StringReplace($sIECacheDir, '%USERPROFILE%', @UserProfileDir)
    Return SetError(0, 0, $sIECacheDir)
EndFunc   ;==>_IE_GetCacheDir

 


February 26, 2017: New SciTE4AutoIt3 available with the updated SciTE v3.7.3 release
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2017-02-26
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites
11 hours ago, Dent said:

Q2. I have only been able to close the tab manually, I have tried _IEAttach to the new tab and then _IEQuit but it doesn't work. I think I would need to interact with the interface by simulating a mouse-click.

Can you post here HTML snippet with this second IE tab ?
_IEAttach works ?
Try to change IE content before Quit, just like that:

Local _IEAttach(......
    $sHTML = _
            "<HTML>" & @CRLF & _
            "<HEAD>" & @CRLF & _
            "<TITLE>Empty Page</TITLE>" & @CRLF & _
            "</HEAD>" & @CRLF & _
            "</HTML>" & _
            ""
    _IEDocWriteHTML($oIE, $sHTML)
    _IEQuit($oIE)

 


February 26, 2017: New SciTE4AutoIt3 available with the updated SciTE v3.7.3 release
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2017-02-26
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

The new IE tab that is created just displays the pdf so I cannot control it with any _IE functions and there is no HTML source to view.

I think I'll have to control the window in some other way :(

Share this post


Link to post
Share on other sites

 

8 minutes ago, Dent said:

displays the pdf so I cannot control it with any _IE functions and there is no HTML source to view.

Are you sure ?

Try this:

#include <IE.au3>

_Example()
Func _Example()
    Local $sURL = 'http://lipok.pl/test_pdf/nicniewidac.html'

    Local $oIE = _IECreate($sURL)
    Local $sHTML = _IEDocReadHTML($oIE)
    MsgBox(0, '', $sHTML)

    $sHTML = _
            "<HTML>" & @CRLF & _
            "<HEAD>" & @CRLF & _
            "<TITLE>Empty Page</TITLE>" & @CRLF & _
            "</HEAD>" & @CRLF & _
            "</HTML>" & _
            ""

    _IEDocWriteHTML($oIE, $sHTML)

EndFunc   ;==>_Example

 

When this MsgBox PopUp try to use F12 (I know do not not works), but then try Developers Tools from IE Menu >>  Tool's

 

 

43 minutes ago, Dent said:

The new IE tab that is created just displays the pdf so I cannot control it with any _IE functions

Here is another interesting example:

 


February 26, 2017: New SciTE4AutoIt3 available with the updated SciTE v3.7.3 release
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2017-02-26
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

Did you try my snippet from #13

??

btw.
If I'm thinking correctly you can use :

using one of this:
_WinINet_FindFirstUrlCacheEntryEx
_WinINet_FindNextUrlCacheEntryEx
_WinINet_FtpCommand
_WinINet_InternetFindNextFile

 


February 26, 2017: New SciTE4AutoIt3 available with the updated SciTE v3.7.3 release
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2017-02-26
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

Would anyone be able to VNC into my machine and try to resolve this?

I would happily give the login details out but there is an email verification process that means I would need to be involved, if you VNC to my machine it is already configured correctly.

mLipok, yes I tried your snippet from #13 but it didn't work.

Share this post


Link to post
Share on other sites

Another option, for whatever it's worth, would be to use WinHttp. Forum thread here.

1 person likes this

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

Quick example (from here):

#include "WinHttp.au3"
Global $hOpen = _WinHttpOpen()
Global $hConnect = _WinHttpConnect($hOpen, 'daveismyname.com')
Global $hRequest = _WinHttpOpenRequest($hConnect, 'POST', '/demos/formpdf/', Default, 'https://daveismyname.com/demos/formpdf/')
_WinHttpSendRequest($hRequest, 'Content-Type: application/x-www-form-urlencoded', 'name=Dent&email=dent%40wayfarer.com&submit=Submit')
_WinHttpReceiveResponse($hRequest)
If _WinHttpQueryDataAvailable($hRequest) Then
    Global $sHeaders = _WinHttpQueryHeaders($hRequest)
    Global $sFile = @ScriptDir & '\' & StringRegExpReplace($sHeaders, '(?si).*filename="(\S+)".*', '$1')
    Global $dChunk, $dData
    While 1
        $dChunk = _WinHttpReadData($hRequest, 2)
        If @error Then ExitLoop
        $dData = _WinHttpSimpleBinaryConcat($dData, $dChunk)
    WEnd
    Global $hFile = FileOpen($sFile, 26)
    FileWrite($hFile, $dData)
    FileClose($hFile)
    If Not FileExists($sFile) Then MsgBox(48, "Error occurred", "No file created." & @CRLF)
    ShellExecute($sFile)
Else
    MsgBox(48, "Error occurred", "No data available." & @CRLF)
EndIf
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

 

Edited by GMK
Correct code; add link
2 people like this

Share this post


Link to post
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

  • Similar Content

    • 31290
      By 31290
      Hi Guys, 
      Since I'm able to get a Dell equipment warranty status thanks to my API key, I'm using an UDF to extract data from an XML file and get the end date. > 
      Thing is, when using InetGet, the original file is in JSON format and the UDF is not working anymore, even if I download the file with the xml extension. Therefore, and when I manually download the page with Chrome, I have a proper XML file where the UDF is working fine.
      Here's my code:
      I even tried to convert the json to xml > https://www.autoitscript.com/forum/topic/185717-js-json-to-xml/
      I took a look here https://www.autoitscript.com/forum/topic/104150-json-udf-library-fully-rfc4627-compliant/ but I don't understand anything :/
       
      The XML read UDF is just perfect for my needs but I'm stuck here... 
      Thanks for any help you can provide
      -31290-
      3MTXM12.json
      3MTXM12.xml
    • mjolnirmarkiv
      By mjolnirmarkiv
      Hi!
      Does anyone have any idea why Test() returns 0, while Test2() returns 1?
      #include <IE.au3> MsgBox(0, "", Test() & " " & Test2()) Func Test() Local $oHTML = ObjCreate("HTMLFILE") $oHTML.body.innerHTML = FileRead("Test.html") Return IsObj($oHTML.getElementsByClassName("example")) EndFunc Func Test2() Local $oIE = _IEAttach("", "instance", 1) Return IsObj($oIE.document.getElementsByClassName("example")) EndFunc Sample Test.html I open in IE before testing:
      <!DOCTYPE html> <html> <body> <p class="example"></p> <div class="example"></div> </body> </html> I'm receiving html text in a response to http request, I need to parse it fast and easy, getElementsByClassName would have been ideal. I'm using 3.3.12.0 version.
    • ADIN
      By ADIN
      When at some page i access by  IE.au3 appears javascript alert all my code stops and i cant do nothing. Is there any way to stop executing javascript at this page or any way to force autoit to click "OK" when this alert appears?
       
      _IENavigate($oIE, "www.example.com") _IELoadWait($oIE) ; site is loaded and alert appears Send("{ENTER}") ;i want to close alert, this command is not executed, whole script is freeze ; cant do nothing more here....  
    • ADIN
      By ADIN
      I want use _IEFormGetCollection to get form content which was generated by javascript
      Local $oIE = _IECreate("https://www.example.com/login.html") ;Open the login page Local $oSpans = _IETagNameGetCollection($oIE, "span") For $oSpan In $oSpans if $oSpan.innertext == "Login" Then _IEAction($oSpan, "click") EndIf Next ;click span which ganerate by javascript login form Local $oForm = _IEFormGetCollection($oIE, 0) ;get my form, but that was not on website after loading, appears after click button and this function cant see it Local $oEmail = _IEFormElementGetObjByName($oForm, "email") ; trying to parse form but cant _IEFormElementSetValue($oEmail, "example@gmail.com") ; _IEFormGetCollection dont see generated dynamically elements Is here any way to _IETagNameGetCollection read website content again after i inititate a javascript which generate additional content?
    • dumbledown
      By dumbledown
      Hi,
      I'm new to AutoIt but it looks great.
      I want to get the text from Internet Explorer when hovering the mouse over an image, the statusbargettext function appears to be the way to go.
      When running via a hotkey I return a blank, but the msgbox works. Do you know what I'm doing wrong?
      Thanks
      HotKeySet("!x", "RecordURL") ;wait for ALT-a keystroke While 1 ;loop forever to wait for the keypress Sleep(100) ;no need to kill the CPU WEnd Func RecordURL() #include <MsgBoxConstants.au3> AutoItSetOption("WinTitleMatchMode", 2) Local $sText = StatusbarGetText("Internet Explorer") MsgBox($MB_SYSTEMMODAL, "", "Internet Explorer's status bar says: " & $sText) EndFunc