添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. im trying to save a website html into a text document without it asking me were to save and if its ok to overwrite this is what i have been using
web.Document.execCommand "SaveAs", False, "data.text"
it works but i need it to not ask me were to save it to any ideas/help? You can't stop the SaveAs box from appearing. Only way would be using a timer and FindWindow. When that window is found, generate keystroke by a simple SendKeys or keyb_event / PostMessage .
But this method is not very good.
to save the webpage as plain text and as html (without images and styles) you can do this,
VB Code:
  1. Private Sub Command1_Click()
  2.  
  3.     Dim Ftxt As Integer
  4.     Dim Fhtm As Integer
  5.  
  6.     '-----------------
  7.     Ftxt = FreeFile
  8.     Open "C:\data.txt" For Output As #Ftxt
  9.     Print #Ftxt, WebBrowser1.Document.body.InnerText 'Saves as text
  10.     Close #Ftxt
  11.     '-----------------
  12.     Fhtm = FreeFile
  13.     Open "C:\data.htm" For Output As #Fhtm
  14.     Print #Fhtm, WebBrowser1.Document.body.InnerHTML 'Saves as HTML
  15.     Close #Fhtm
  16.  
  17. End Sub
You can directly download the file by URLDownloadToFile.shtml
To silently save the document with images etc, you'll need to either string parse the document to get the images urls
or better, do the way IE does - loop through DOM, get the image addresses, look for them in cache. If they are found in cache, copy them. Otherwise, download them. thanks i dont need the images or anything my program just saves the page as html then searches thrue it for keywords
edit: that worked perfectly thanks Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.