I need help to get start with my app.
I try to get HREF link from webpage without webbrowser.
I use HtmlAgilityPack but i cant get the spefic HREF:
<a id="ItemsList_file_0" title="HR9nqJCIqHex8niygKtwUHpdkjRGNaH22Oy54SPBmw.avi" href="http://dsa11.uverload.com/d/a012284e-1fd5-4317-82d3-9bf9e738f0a2/BIfmZ/0lOipBI/HR9nqJCIqHex8niygKtwUHpdkjRGNaH22Oy54SPBmw.avi" target="_blank">HR9nqJCIqHex8niygK..22Oy54SPBmw.avi</a><br />
i try this code .
Dim webreq As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://www.uverload.com/view/0lOipBI")
Dim webres As System.Net.HttpWebResponse = webreq.GetResponse
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(webres.GetResponseStream)
Dim docStr As String = sr.ReadToEnd
Dim HAPdoc As New HtmlAgilityPack.HtmlDocument
HAPdoc.LoadHtml(docStr)
Dim HAPnode As HtmlAgilityPack.HtmlNode
HAPnode = HAPdoc.GetElementbyId("ItemsList_file_0")
MsgBox(HAPnode.InnerText)
End Sub
give me nothing
Related
I'm trying to zip a set of pdf files and send to client as download.
No matter what combinations of Response settings I try, the code doesn't throw any exception and apparently the zip file stream is created fine, but the file is not sent to the client as a download and when you hit the download button nothing happens.
Private Sub lkbDownloadPdfs_Click(sender As Object, e As System.EventArgs) Handles aDownloadPdfs.ServerClick
Try
Dim WSStockToolAuthTokenUrl As String = ConfigurationManager.AppSettings("WSStockToolAuthTokenUrl")
Dim auth As AuthenticationHeader = Utility.GetAuthenticationForStockToolToken()
Dim token As String = Utility.GetInitializationToken(WSStockToolAuthTokenUrl, auth.UserName, auth.password)
Response.Clear()
Response.ContentType = "application/zip"
Response.AppendHeader("Content-Disposition", "attachment; filename=files.zip")
If (token IsNot Nothing) Then
Dim result As String = PDFApiCallResult(token)
Dim pdfPathList As List(Of String) = Utility.GeneratePDFList(result)
If (pdfPathList.Count = 1) Then
Dim pdfPath As String = pdfPathList.ElementAt(0)
Dim strFile As String
Dim strmZipOutputStream = New ZipOutputStream(Response.OutputStream)
strmZipOutputStream.SetLevel(9)
Dim objCrc32 As New Crc32()
For Each strFile In pdfPathList
Dim Client As WebClient = New WebClient()
Dim strmFile As Stream = Client.OpenRead(strFile)
Dim reader As StreamReader = New StreamReader(strmFile)
Dim Content As String = reader.ReadToEnd()
Dim abyBuffer(Convert.ToInt32(Content.Length - 1)) As Byte
Dim sFile As String = Path.GetFileName(strFile)
Dim theEntry As ZipEntry = New ZipEntry(sFile)
theEntry.DateTime = DateTime.Now
theEntry.Size = Content.Length
strmFile.Close()
objCrc32.Reset()
objCrc32.Update(abyBuffer)
theEntry.Crc = objCrc32.Value
strmZipOutputStream.PutNextEntry(theEntry)
strmZipOutputStream.Write(abyBuffer, 0, abyBuffer.Length)
Next
strmZipOutputStream.Flush()
strmZipOutputStream.Finish()
strmZipOutputStream.Close()
Response.Flush()
Response.Close()
Response.SuppressContent = True
HttpContext.Current.ApplicationInstance.CompleteRequest()
Else
End If
End If
Catch ex As Exception
ExceptionManager.Publish(ex)
End Try
End Sub
Any help? (If you have working C# code I could try to convert it to vb.net too)
Update 1: This is the aspx where the link which does the callback resides:
<asp:UpdatePanel runat="server" ID="updImages" UpdateMode="Conditional">
...
DOWNLOAD PDFS
...
<asp:AsyncPostBackTrigger ControlID="lkbAddToWishlist" />
<asp:AsyncPostBackTrigger ControlID="ddlCustomizations" />
</asp:UpdatePanel>
I've read that maybe the response is not working at all because of the ajax way the update panel does the postback, but not sure about that and how to deal with that.
In my program, I get a series of information instantly from several Internet addresses on a one-to-one basis, but this is delay time and this delay may be part of the momentary information loss . I want to get all the information from all URLs at the same time. Is it possible?
This is part of my program:
For i As Integer = 0 To 1000
Dim wreq As System.Net.HttpWebRequest =
System.Net.WebRequest.Create("http://www........." + slink(i))
wreq.AutomaticDecompression = Net.DecompressionMethods.GZip
Dim wres As System.Net.WebResponse = wreq.GetResponse
Dim s As System.IO.Stream = wres.GetResponseStream
Dim sr As New System.IO.StreamReader(s)
Dim html As String = sr.ReadToEnd
Dim sOutput As String = html
Dim file As System.IO.StreamWriter
Dim masir As String = TextBox1.Text & "tm\Archive\" + slink(i).ToString
file = My.Computer.FileSystem.OpenTextFileWriter(masir, True)
file.Write(html)
file.Close()
Next
Hello I am trying to get the "title" element out of this table:
<td class="field_domain"><strong>Plantar</strong><strong>Fasciitis</strong>HeelPain.com</td>
Here is my code that almost works but not quite:
Dim web As New HtmlAgilityPack.HtmlWeb()
Dim htmlDoc As HtmlAgilityPack.HtmlDocument = web.Load("https://www.expireddomains.net/domain-name-search/?o=domainpop&r=d&q=plantar+fasciitis")
Dim html As String = htmlDoc.DocumentNode.OuterHtml
Dim tabletag = htmlDoc.DocumentNode.SelectNodes("//td[#class='field_domain']")
For Each t In tabletag
Dim var = t.SelectSingleNode("//td[#class='title']").InnerText
MessageBox.Show(var)
Next
This did the trick:
Dim web As New HtmlAgilityPack.HtmlWeb()
Dim htmlDoc As HtmlAgilityPack.HtmlDocument = web.Load("https://www.expireddomains.net/domain-name-search/?o=domainpop&r=d&q=plantar+fasciitis")
Dim html As String = htmlDoc.DocumentNode.OuterHtml
For Each linkItem As HtmlNode In htmlDoc.DocumentNode.SelectNodes("//td[#class='field_domain']")
Dim name = linkItem.Element("a").InnerText
MessageBox.Show(name)
Next
How Can I extract href text from website?
<div class="ba by">**I want this text!**</div>
I try some solution, but doesn't work.
Dim myMatches As MatchCollection
Dim myRegex As New Regex("<div.*?class=""ba by"".*?>.*</div>", RegexOptions.Singleline)
Dim wc As New WebClient
Dim html As String = wc.DownloadString("http://somewebaddress.com")
TextBox1.Text = html
myMatches = myRegex.Matches(html)
MsgBox(html)
Dim successfulMatch As Match
For Each successfulMatch In myMatches
MsgBox(successfulMatch.Groups(1).ToString)
Next
or
Dim divs = WebBrowser1.Document.Body.GetElementsByTagName("div")
For Each d As HtmlElement In divs
If d.GetAttribute("class") = "ba by" Then
TextBox1.Text = d.InnerText
End If
Next
Thank you!
Instead of ...
Dim divs = WebBrowser1.Document.Body.GetElementsByTagName("div")
Try...
Dim anchors = WebBrowser1.Document.Body.GetElementsByTagName("a")
That should get you a list of all the "
I am writing code where I am trying to grab the HTML from a DNS report online (http://viewdns.info/dnsreport/?domain=google.com), but I am having some issues. The one line of the HTML file (Line 231) that I actually need is cutting itself off after around 680 characters. All of the lines after the important one are reading correctly, however. The code for grabbing the HTML is shown below, and I have tried it in two separate ways.
This is the first way I tried:
Public Function getWebResourceData(ByVal strURL As String) As String
Dim webClient As New System.Net.WebClient
Dim result As String = webClient.DownloadString("http://viewdns.info/dnsreport/?" & TextBox1.Text)
return result
End Function
And this is the second:
Public Function getWebResourceData(ByVal strURL As String) As String
Dim rt As String = ""
Dim wRequest As WebRequest
Dim wResponse As WebResponse
Dim SR As StreamReader
wRequest = WebRequest.Create(strURL)
wResponse = wRequest.GetResponse
SR = New StreamReader(wResponse.GetResponseStream)
rt = SR.ReadToEnd
SR.Close()
return rt
End Function
Im really not sure what else could be wrong at this point. I have also tried saving the result to a text file to see if that was the issue, but that was incorrect as well. I have looked into the hex codes for the area where the string is stopping, but there isn't anything out of the ordinary. The split occurs between the back to back alligator brackets (shown as parentheses) here: (/tr)(tr)
But there are numerous sets of these tags throughout the HTML that there are no issues with.
Both of your functions don't return what they have read. I have tested the second one and it works correctly.
Sub Main
Dim ret = getWebResourceData("http://viewdns.info/dnsreport/?domain=google.com")
Console.WriteLine(ret.Length)
' Output = 21605
End Sub
Public Function getWebResourceData(ByVal strURL As String) As String
Dim rt As String = ""
Dim wRequest As WebRequest
Dim wResponse As WebResponse
Dim SR As StreamReader
wRequest = WebRequest.Create(strURL)
wResponse = wRequest.GetResponse
SR = New StreamReader(wResponse.GetResponseStream)
rt = SR.ReadToEnd
SR.Close()
return rt
End Function