As funções a serem implementadas são mostradas na figura a seguir. Os detalhes específicos são os seguintes:
Agora vou apresentar algumas outras funções do software. Espero que todos se beneficiem.
Produtos de pesquisa de simulador
Ao escovar os pedidos, você não pode obter diretamente um URL do produto e inserir a página de compra. Você precisa simular uma pesquisa artificial.
Existem duas dificuldades neste processo:
1) carregamento assíncrono da lista de produtos; 2) gire as páginas e tire capturas de tela;
No jardim, não brinco com uma grande espada em frente a Guan Gong.
Faça o upload diretamente do código da chave:
I: Procure por produtos e virar páginas
Public Bool? SearchProduct (TaskDetailModel TaskDetailData) {bool? resultado = null; bool isIndex = true; bool islist = true; webbrowSertosk.instance.setProperties (); webBrowStosk.instance.cleardocumentCompleted (); webbrowsTask.Instance.DocumentComCleted += (WBSErSearch, wbesearch) => {systemer. {systemerw.w.EsterSearch.Imtance.documentConw.w.Est.W.Est.W.Imtance.Imtance.DocumentEn. wbssendersearch como system.windows.forms.webbrowser; system.windows.forms.htmldocument currentDoc = currentwb.document; mshtml.htmldocumentdom = currentlDoc.domDocument como mshtml.htmlding; System.windows.forms.webbrowserReadyState.complete) {#Pesquisa doméstica da região if (wburl.contains ("www.taobao.com")) {if (isIndex == true) {isindex = false; taskDetaildata.detailRemark = string.format ("enter. TaskDetaildata.TaskName); func <BOOL> func = () => {bool assínctag = false; system.threading.thread.sleep (5000); assynctag = true; retorna asynctag;}; func.beginvoke ((ar) => {bOol como (asyncresult) {System.windows.forms.htmlelement heee = currentDoc.getElementById ("j_searchTab"); string className = heee.getAttribute ("ClassName"; System.Windows.Forms.htMlementMEMEMENTEM = HELEMEN.CLELTEN; hitem.Children; System.Windows.Forms.htmlelement li1 = heclis [0]; System.windows.forms.htmlelement li2 = heclis [1]; System.windows.forms.htmlement li3 = heclis [2] em heliMel (SystemS.l ).htmlement li3 = heclis [2]; li.getAttribute ("ClassName"); if (Liclass.Contains ("Selected")) {System.windows.forms.htmlelement q = currentDoc.getElementById ("q"); System.Windows.Forms.htmleLement BtNearch = currentDoc.getElementIdIdIdIdIdIds.HtmlemErch = != null && btnsearch != null){q.Focus();q.SetAttribute("value", taskDetailData.TaskName);btnsearch.Focus();string savePath = Path.Combine(UserData.WorkBenchDirectory, taskDetailData.TaskDetailCode, String.Format("Search Submission.jpg", "")); CaptureImage.captureWebPageea (CurrentDom, salvina); Btnsearch.invokemember ("Click");}}}}}}}, null);}}#endregion home Search#Region Product List (ifburl.contains ("S.TaOBao.com) {sear false; func <BOOL> func = () => {bool assínctag = false; asynctag = true; retorna assíncrag;}; func.begininvoke ((ar) => {bool asyncresult = func.endinvoke (ar); if (asyrCresult) {/ Analisá -lo. TaskDetailData); resultado = true;}}, null);}}#list de produtos Endregion}}; // documentCompleted end System.windows.application.current.dispatcher.invoke (new System.action (() => {webbrowstsask.instance.navigate ("https://www.taobao.com/"); (resultado! = null) {break;}} Return Result;} II: Como cada página é carregada de forma anormal, escolha o tempo apropriado para tirar uma captura de tela da página da web e capturar toda a página da web:
/*Because the control is included, if it is called in the thread, the Invoke method must be used with System.Windows.Application.Current.Dispatcher.Invoke(new System.Action(() =>{//htmlDoc.Window.ScrollTo(new System.Drawing.Point(5000, htmlDoc.Body.ScrollRectangle.Height));string savePath = String.Format (@"D:/{0} .jpg", GUID.NewGuid (). ToString ()); CaptureImage.CaptureWebPage (WebBrowsTask, SalvePath);}), System.Windows.Threading.DispPriority.background);}), System.Windows.Threading.DispPriority.background); </summary> //// <param name = "web"> </am Param> //// <param name = "salvAthy"> </am> public static void CaptureWebPage (System.Windows.Forms.WebBrowser Web, stringpath) {retangn = web.document.body..ScrollectGrange; novo tamanho (Body.Width, Body.Height)}; web.dock = Dockstyle.None; Web.Width = DocRectangle.Width; Web.Height = DocRectangle.Height; Rectangle ImGrectangle = DocRectangle; usando (bitmap bitmap = new bitmap (iMGrectangle.Width, imGrectangle.Height)) {IViewObject IVO = web.document.domdocument como IViewObject; usando (Graphics g = graphics.Fromimage (bitmap)) {intptr hdc = g.gethDc (); Intptr.Zero, intptr.Zero, HDC, Ref ImGrectangle, Ref DocRectangle, intptr.Zero, 0); G.ReleaseHdc (HDC);} Bitmap.Save (SavePath, System.Drawing.Imaging.ImageMattat) Inscreva uma determinada área da página da web:
/// <summary>//// Intercept part of the web page /// </summary>/// <param name="htmlDom"></param>/// <param name="savePath"></param>public static void CaptureWebPageArea(mshtml.HTMLDocument htmlDom, String savePath){String saveDir = System.io.path.getDirectoryName (savePath); if (! System.io.directory.exists (savedir)) {system.io.directory.createDirectory (savedir);} retângulo DocRectangle = newsTrangn () {Location = new Point (0), // tamanho = tamanho (size (size (size. htmldom.body.offsetHeight) tamanho = novo tamanho ((int) System.windows.systemParameters.PrimaryScreenWidth, (int) System.Windows.SystemParameters.PrimaryScreenHeight)}; usando (bitmap bitmap = new bitmap (iMGrectangle.Width, imGrectangle.Height)) {IViewObject IVO = htmldom como IViewObject; usando (graphics g = graphics.fromImage (bitmap)) {intptr, g.gethdc (); Intptr.Zero, intptr.Zero, HDC, Ref ImGrectangle, Ref DocRectangle, intptr.Zero, 0); G.ReleaseHdc (HDC);} Bitmap.Save (SavePath, System.Drawing.Imaging.ImageMattat) Existem muitos trechos interessantes neste código. Amigos interessados vão descobrir.