|
-
Feb 17th, 2013, 02:13 PM
#1
Thread Starter
Lively Member
Making webbrowser focus on one part of a website
Hey
Can anyone tell me / help me find the solution to this:
Is there anyway i can have a webbrowser only show the top two or three tweets from a twitter account? (https://twitter.com/pewdiepie)
Like, remove all the other objects on the page, and then center the tweets in the webbrowser?
Im kinda guessing that without some hardcore coding i will only be able to show ALL the tweets, not just the two or three newest.
Here is a code i found for hiding website objects from being shown in the browser:
Code:
Dim ele = _
( _
From X In WebBrowser3.Document.GetElementsByTagName("div").Cast(Of HtmlElement)() _
Where X.GetAttribute("id") = "[ID OF ELEMENT]" Select X
).FirstOrDefault
If ele IsNot Nothing Then
ele.Style = "Display:none"
End If
I don't know how this works, but if there would be any options like replacing
Code:
ele.Style = "Display:none"
with
Code:
ele.Style = "Display:only"
or something like that, to only show the object in question, we would be half way there :P
Anyone got any ideas? Thanks for all replies. (I apologize for my bad english)
-
Feb 18th, 2013, 02:53 PM
#2
Thread Starter
Lively Member
Re: Making webbrowser focus on one part of a website
-
Feb 18th, 2013, 03:46 PM
#3
Re: Making webbrowser focus on one part of a website
I have to say I can't really see any point to this but I did try a few ideas without success. If you wanted to extract the first few and transfer them to a new page or another control that would probably be possible but if you want to retain the rest of the page then it looks like a bit of a dead end.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Feb 18th, 2013, 03:51 PM
#4
Thread Starter
Lively Member
Re: Making webbrowser focus on one part of a website
 Originally Posted by dunfiddlin
I have to say I can't really see any point to this but I did try a few ideas without success. If you wanted to extract the first few and transfer them to a new page or another control that would probably be possible but if you want to retain the rest of the page then it looks like a bit of a dead end.
I wouldn't neccesarily need to keep the tweets in the webbrowser. I could just set that to webbrowser.visible = false then have the tweets show up in some other kind of control. (Like putting them in labels.)
The main point is that i need the two or three (Hopefully three) tweets to show up somewhere so you can easily read it.
-
Feb 18th, 2013, 05:06 PM
#5
Re: Making webbrowser focus on one part of a website
Ok here you go. The function returns HTML so show the results in a webbrowser (wb1 in this case)
vb.net Code:
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
wb1.DocumentText = ""
wb1.Document.Write(Get3Tweets("https://twitter.com/pewdiepie"))
End Sub
Private Function Get3Tweets(ByVal url As String) As String
Dim wc As New Net.WebClient
Dim htm = wc.DownloadString(url)
Dim wb As New WebBrowser With {.DocumentText = ""}
wb.Document.Write(htm)
Dim tweets = From t In wb.Document.GetElementsByTagName("p") Where CType(t, HtmlElement).GetAttribute("classname") = "js-tweet-text"
Dim s As New System.Text.StringBuilder
For i = 0 To 2
s.Append("<p>" & CType(tweets(i), HtmlElement).InnerHtml)
Next
wb.Dispose()
Return s.ToString
End Function
End Class
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Feb 19th, 2013, 02:21 AM
#6
Thread Starter
Lively Member
Re: Making webbrowser focus on one part of a website
 Originally Posted by dunfiddlin
Ok here you go. The function returns HTML so show the results in a webbrowser (wb1 in this case)
Well... Ehm... minor problem. (Unrelated to the code you sent me) but im still gonna ask:
I have two groupboxes that show statistics and ranking. The webbrowser "wb1" is layed on top of those.
I was planing to hide the groupboxes by "GroupBox1.visible = false" and "GroupBox2.visible = false". And set the webbrowser to visible = true.
But the webbrowser is apperantly "connected" to the groupboxes as if it is a control within them. And when i hide the groupboxes, the webbrowser doesn't show because of it.
Can i seperate the webbrowser from the groupboxes somehow? (While having both the groupboxes and the webbrowser at the same location?
-
Feb 19th, 2013, 04:27 AM
#7
Thread Starter
Lively Member
Re: Making webbrowser focus on one part of a website
Nevermind. Fixed it.
Used alot of [Name of control].location = New Point(#, #)
-
Apr 21st, 2013, 12:14 PM
#8
Hyperactive Member
Re: Making webbrowser focus on one part of a website
I've been trying to adopt dunfiddlin code to be able to get data back from :
Code:
<div class="content"> some text <br /></div>
...but i'm having a hard time. could someone guide me to the solution?
Thanks for helping me out.
-
Apr 21st, 2013, 12:30 PM
#9
Re: Making webbrowser focus on one part of a website
If you can guide me to the problem!
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Apr 21st, 2013, 12:37 PM
#10
Hyperactive Member
Re: Making webbrowser focus on one part of a website
hehe 
well, im trying to get the the "some text" from the
Code:
<div class="content"> some text <br /></div>
i tried changing
Code:
("classname") = "js-tweet-text"
to
Code:
("classname") = "content"
but no luck. did other changes to but none seemed to work
Thanks for helping me out.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|