Page 1 of 1

Grabbing text from website

Posted: Thu Jun 09, 2016 4:24 pm
by 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

Re: Grabbing text from website

Posted: Sat Jun 11, 2016 12:03 pm
by 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.

Re: Grabbing text from website

Posted: Sat Jun 11, 2016 11:32 pm
by Filip
CodenStuff wrote:
[/b]ID tag
ID attribute you mean?

Re: Grabbing text from website

Posted: Sun Jun 19, 2016 10:47 pm
by 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?

Re: Grabbing text from website

Posted: Thu Sep 29, 2016 7:02 am
by 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";