Jump to content

Some guy plz help me


Recommended Posts

first one, i'm sorry for my bad english. Actually, it's very bad
I had a problem when i tried to get the HTML code of the Element object in a webpage. When i run my code, it'd not come off as i hoped
This is my code

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.12.0
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <IE.au3>
#include <FileConstants.au3>

Global $_browser

$_browser =_IECreate("about:blank")

For $i =1 to 20249
    Local $link, $_getIDbrowser, $_getIDelement
    $link="http://tratu.coviet.vn/hoc-tieng-anh/cap-cau-song-ngu/vietgle-tra-tu/tat-ca/trang-"&$i&".html"
    _IENavigate($_browser,$link)
    $_getIDbrowser = _IEGetObjById($_browser , "ctl00_ContentPlaceHolderMain_ctl00")
    $_getIDelement = _IEPropertyGet($_getIDbrowser,"innerhtml")
        writefile($_getIDelement)
    $_getIDelement=""
    Sleep(100)
Next


func writefile($line)
    $file= FileOpen("C:\exports.html",129)
    FileWriteLine($file,$line)
    FileClose($file)
EndFunc

 

Link to comment
Share on other sites

Welcome to AutoIt and the forum!

Can you please tell us what kind of information you try to grab from 20249 web pages?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Welcome to AutoIt and the forum!

Can you please tell us what kind of information you try to grab from 20249 web pages?

Oh, sorry i forgot to say it. I want to save the english sentences to serve for my learning english. But I feel it difficult to obtain data in text format. So I decided to take it in the form of HTMT. In that pageIt is the data in the path from  "... .trang-1.html" to "... .trang-20429.html".When I run my script, it only runs until "..... trang-2.html" then stop. The output file do not have to add any more data. That's my problem. I tried to change the variable $i=3 but i got one more time. It's still not succeed

Edited by quimao
Link to comment
Share on other sites

Your English is fine, but you're not getting your point across.

Best guess...

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.12.0
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <IE.au3>
#include <FileConstants.au3>

Global $_browser

$_browser =_IECreate("about:blank")

$file= FileOpen("C:\exports.html",129)

For $i =1 to 20249
    Local $link, $_getIDbrowser, $_getIDelement
    $link="http://tratu.coviet.vn/hoc-tieng-anh/cap-cau-song-ngu/vietgle-tra-tu/tat-ca/trang-"&$i&".html"
    _IENavigate($_browser,$link)
    $_getIDbrowser = _IEGetObjById($_browser , "ctl00_ContentPlaceHolderMain_ctl00")
    $_getIDelement = _IEPropertyGet($_getIDbrowser,"innerhtml")
        writefile($_getIDelement)
    $_getIDelement=""
    Sleep(100)
Next

FileClose($file)

func writefile($line)
    
    FileWriteLine($file,$line)
    
EndFunc

 

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

What your code is missing is error testing. Check after each function call if it was successful or if the function returned an error.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

To get data in text format you could try this

#include <IE.au3>
#include <FileConstants.au3>

$_browser =_IECreate("about:blank")
$file= FileOpen("exports.txt",129)

For $i =1 to 5
    Local $link, $_getIDbrowser, $_getIDelement
    $link="http://tratu.coviet.vn/hoc-tieng-anh/cap-cau-song-ngu/vietgle-tra-tu/tat-ca/trang-"&$i&".html"
    _IENavigate($_browser,$link)
    $_getIDbrowser = _IEGetObjById($_browser , "ctl00_ContentPlaceHolderMain_ctl00")
    $_getIDelement = StringRegExpReplace(_IEPropertyGet($_getIDbrowser,"innertext"), '\v{2,}', @crlf)
        writefile("___ page " & $i &@crlf&@crlf)
        writefile($_getIDelement)
    Sleep(100)
Next

FileClose($file)

func writefile($line)
    FileWriteLine($file,$line)
EndFunc

 

Link to comment
Share on other sites

@mikell:
Thank you so much, can't believe I could forget this  "innerText" but your script runs just like mine. The Output file only the data record of the first two paths "... trang-1.html" & "........ .trang-2.html" and no added more. Did your script work in all?

@Johnone:
the truth is I only know English expressions like that. I also want to explain more but my knowledge of English is limited. sorry you

@water:
Oh I know, my script runs in the first two paths, and output file write data of that two paths, but from the path of three. It doesn't run anymore

 

Edited by quimao
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...