Grabbing text from website

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
5 posts Page 1 of 1
Contributors
User avatar
Bloodz_Ninja
Dedicated Member
Dedicated Member
Posts: 69
Joined: Sat Aug 25, 2012 3:20 am

Grabbing text from website
Bloodz_Ninja
hey guys, id like to know a probably a snippet or a tutorial on how to grab text from a website in visual basic..
An example of a program will be something like a plagarism checker maybe.

thanks in advanced
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Re: Grabbing text from website
CodenStuff
If you're using a Webbrowser control you can grab the content of elements on a webpage like this:
Code: Select all
WebBrowser1.Document.GetElementById("ID-of-the-element").GetAttribute("innerText")
Where "ID-of-the-element" would be the ID tag of whichever element you want to pull content from.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
Filip
Coding Guru
Coding Guru
Posts: 833
Joined: Wed Jan 05, 2011 3:59 pm

Re: Grabbing text from website
Filip
CodenStuff wrote:
[/b]ID tag
ID attribute you mean?
CodenStuff wrote:
Nope, it's just your sick and dirty mind. You sick twisted warped little pervo :D
User avatar
Bloodz_Ninja
Dedicated Member
Dedicated Member
Posts: 69
Joined: Sat Aug 25, 2012 3:20 am

Re: Grabbing text from website
Bloodz_Ninja
CodenStuff wrote:
If you're using a Webbrowser control you can grab the content of elements on a webpage like this:
Code: Select all
WebBrowser1.Document.GetElementById("ID-of-the-element").GetAttribute("innerText")
Where "ID-of-the-element" would be the ID tag of whichever element you want to pull content from.
thanks man, but the thing is im not good with html or php so the ID thing is new to me. Mind giving an example?
User avatar
mikethedj4
VIP - Site Partner
VIP - Site Partner
Posts: 2592
Joined: Thu Mar 25, 2010 4:36 am

Re: Grabbing text from website
mikethedj4
Bloodz_Ninja wrote:
CodenStuff wrote:
If you're using a Webbrowser control you can grab the content of elements on a webpage like this:
Code: Select all
WebBrowser1.Document.GetElementById("ID-of-the-element").GetAttribute("innerText")
Where "ID-of-the-element" would be the ID tag of whichever element you want to pull content from.
thanks man, but the thing is im not good with html or php so the ID thing is new to me. Mind giving an example?
It's been a loooong time since I touched VB but I'm proficient in HTML, CSS, and JS so I'll shed some light on that here. (See example weave/code on kodeWeave)

HTML = HyperText Markup Language

Example:
Code: Select all
<p id="t1"></p>
<p class="t2"></p>
<p data-call="txt"></p>
<p>
  <span></span>
</p>
In HTML you markup your content. Like on here we use....
Code: Select all
[b]bold[/b]
to make bold text. Similarly it's done in HTML (although all styling should be done in CSS, but that's a topic for another time).
Code: Select all
<strong>bold</strong>
There're many ways to select an element in JS and manipulate it aka DOM manipulation (which is poor in JS, main reason why ReactJS is so popular cause it uses a virtual DOM)

Here's an example of how you can select elements in JS and manipulate their content...
Code: Select all
var t1 = document.getElementById("t1"),
    t2 = document.querySelector(".t2"),
    t3 = document.querySelector("[data-call=txt]"),
    // t4 = document.querySelector("span"),
    t4 = document.getElementsByTagName("span")[0];

t1.innerText   = "Hello";
t2.textContent = "world";
t3.innerText   = "Hola";
t4.textContent = "mundo";
5 posts Page 1 of 1
Return to “Tutorial Requests”