How to Create an eBay Listing Information Grabber in Visual Basic
Submitted by GeePee on Tuesday, March 24, 2015 - 23:01.
Introduction:
Welcome to my tutorial on how to create an eBay Listing Information Grabber in Visual Basic.
Steps of Creation:
Step 1:
First we want to add some imports;
We also want to make a form with; textbox1 - contain the eBay Listing Link, button1 - to begin the information grabbing process.
Step 2:
Next we want to create a custom function which will return a string between two points of strings within a larger string...
Step 3:
Now, on button1 click action event, we want to get the source code of the eBay listing page.
Step 4:
Finally, we want to extract the information from the page source code and output it in a messagebox.
Project Complete!
Below is the full source code and download to the project files.
- Imports System.Text.RegularExpressions
- Imports System.Net
- Imports System.IO
- Private Function GetBetween(ByVal Source As String, ByVal Str1 As String, ByVal Str2 As String, Optional ByVal Index As Integer = 0) As String
- Return Regex.Split(Regex.Split(Source, Str1)(Index + 1), Str2)(0)
- End Function
- Dim r As HttpWebRequest = HttpWebRequest.Create(TextBox1.Text)
- Dim re As HttpWebResponse = r.GetResponse()
- Dim src As String = New StreamReader(re.GetResponseStream()).ReadToEnd()
- Try
- Dim title As String = GetBetween(src, "id=""itemTitle"">", "</h1>")
- Dim price As String = GetBetween(src, "itemprop=""price"">", "</span>")
- MsgBox(title & vbNewLine & price)
- Catch ex As Exception
- MsgBox("Information not found, has the bidding ended?")
- End Try
- Imports System.Text.RegularExpressions
- Imports System.Net
- Imports System.IO
- Public Class Form1
- Private Function GetBetween(ByVal Source As String, ByVal Str1 As String, ByVal Str2 As String, Optional ByVal Index As Integer = 0) As String
- Return Regex.Split(Regex.Split(Source, Str1)(Index + 1), Str2)(0)
- End Function
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- Dim r As HttpWebRequest = HttpWebRequest.Create(TextBox1.Text)
- Dim re As HttpWebResponse = r.GetResponse()
- Dim src As String = New StreamReader(re.GetResponseStream()).ReadToEnd()
- Try
- Dim title As String = GetBetween(src, "id=""itemTitle"">", "</h1>")
- Dim price As String = GetBetween(src, "itemprop=""price"">", "</span>")
- MsgBox(title & vbNewLine & price)
- Catch ex As Exception
- MsgBox("Information not found, has the bidding ended?")
- End Try
- End Sub
- End Class
Add new comment
- 60 views