Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
36 views

C# Programing For Autolisp

This document contains VB.NET code for automating web browser interactions. It includes code to navigate to URLs, retrieve page source, find and set element attributes, and submit forms. The code handles different cases for searching on redbubble.com and using a tag generator. It also includes error handling for invalid URLs.

Uploaded by

The GridLock
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

C# Programing For Autolisp

This document contains VB.NET code for automating web browser interactions. It includes code to navigate to URLs, retrieve page source, find and set element attributes, and submit forms. The code handles different cases for searching on redbubble.com and using a tag generator. It also includes error handling for invalid URLs.

Uploaded by

The GridLock
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Imports System.

Net
Imports System.Text.RegularExpressions
Imports System.Windows.Forms

Public Class Form1


Private Sub AU_btn_Ok_Click(sender As Object, e As EventArgs) Handles
AU_btn_Ok.Click
'Dim str As String = WebBrowser1.DocumentText

'https://www.codeproject.com/Articles/38639/Get-HTML-Source-from-User-
Defined-Web-Address
'https://social.msdn.microsoft.com/Forums/vstudio/en-US/1ddb96ce-359a-4baf-
9ffc-6a87eba4fe26/how-can-i-get-html-page-source-for-websites-in-vbnet?
forum=vbgeneral
'https://snipplr.com/view/70724/get-page-source-code/
'---------------------------------------------------
''Dim SearchText As String
''SearchText = AU_Searchstring.Text
''Dim PageText As String = WebBrowser1.Document.Body.InnerText
''If InStr(PageText, SearchText) > 0 Then
''Else
'' MsgBox("Not Found") : Exit Sub
''End If
Select Case AU_tb_WebLink.Text
Case "https://www.redbubble.com/"
Searchstring = "https://www.redbubble.com/shop/" +
Replace(AU_Searchstring.Text, " ", "+") + "?ref=search_box"
End Select
ServicePointManager.Expect100Continue = True
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
''Dim sourceString As String = Nothing
''Try
'' sourceString = New
System.Net.WebClient().DownloadString(Searchstring)

''Catch ex As System.Net.WebException
'' AU_msgbox("Cann't found this keyword.")
''End Try
''----------------------------------------------------
''Dim file As System.IO.StreamWriter
''file = My.Computer.FileSystem.OpenTextFileWriter("C:
\Users\AU_Express\Desktop\mytext.txt", True)
''file.WriteLine(sourceString)
''file.Close()
''-----------------------------------------------------
'Dim regex As Regex
'regex = New Regex("(?<=<strong>)((?!(Previous|Next)))[^<>].+?(?
=<\/strong>)")
'Dim match As Array = regex.Matches(sourceString).Cast(Of Match).ToArray
'Dim a As SByte = UBound(match, 1)
'Dim value(a) As Object, i As SByte
'For Each item As Match In match
' value(i) = item.Value
' i += 1
'Next
'ClsAuribbon2.GLBExapp.Range("A1").Resize(a + 1, 1).Value2 =
ClsAuribbon2.GLBExapp.WorksheetFunction.Transpose(value)
'-----------------------------------------------
'tiep tuc trang web thu 2
Searchstring = "https://automation.merchtitans.com/tools/redbubble-tag-
generator"
Try

If AU_tb_WebLink.Text <> vbNullString Then


WebBrowser1.Navigate(Searchstring)
End If
Catch ex As Exception
AU_msgbox("URL invalid.")
End Try

'Dim objs As HtmlElementCollection =


WebBrowser1.Document.GetElementsByTagName("input")
Dim objs As HtmlElement = WebBrowser1.Document.GetElementById("tag")
objs.SetAttribute("text", "abc")
'For Each obj As HtmlElement In objs
' If obj.GetAttribute("name") = "query" Then
' obj.SetAttribute("value", AU_Searchstring.Text) : Exit For
' End If
'Next

'Dim sourceString As String = Nothing


'Try
' sourceString = New System.Net.WebClient().DownloadString(Searchstring)

'Catch ex As System.Net.WebException
' AU_msgbox("Cann't found this keyword.")
'End Try

End Sub
Private Searchstring As String
'Private Sub AU_Negative_Click(sender As Object, e As EventArgs) Handles
AU_Negative.Click
' Searchstring = AU_tb_WebLink.Text '"https://www.redbubble.com/shop/" +
Replace(AU_tb_WebLink.Text, " ", "+") + "?ref=search_box"
' Try

' If AU_tb_WebLink.Text <> vbNullString Then


' WebBrowser1.Navigate(Searchstring)
' End If
' Catch ex As Exception
' AU_msgbox("URL invalid.")
' End Try
' ServicePointManager.Expect100Continue = True
' ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
' Dim sourceString As String = New
System.Net.WebClient().DownloadString(Searchstring)
' 'RichTextBox1.Text = sourceString
'End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

End Sub
'https://www.youtube.com/watch?v=oXlxYj4otHo
'Private Sub AU_btn_import_Click(sender As Object, e As EventArgs) Handles
AU_btn_import.Click

' Dim objs As HtmlElementCollection =


WebBrowser1.Document.GetElementsByTagName("input")
' For Each obj As HtmlElement In objs
' If obj.GetAttribute("name") = "query" Then
' obj.SetAttribute("value", AU_Searchstring.Text) : Exit For
' End If
' Next
' 'https://stackoverflow.com/questions/11101060/programatically-clicking-an-
html-button-by-vb-net
' Dim l_forms As HtmlElementCollection =
WebBrowser1.Document.GetElementsByTagName("form")
' l_forms.Item(0).InvokeMember("submit")
' 'WebBrowser1.Document.GetElementById("searchBox").InvokeMember("submit")

'End Sub

End Class

You might also like