Efficiently extracting webpage data into a data structure with JavaScript [closed] - javascript

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am new to JS and I am trying to figure out the most efficient way to perform this task.
Stack Exchange keeps a list of its member-sites at https://stackexchange.com/sites
What is the most efficient way to extract this data into a data-structure, like an array or dictionary in JavaScript?

It seems like all the stackexchange sites are built with the same framework. If you check in your console, you can see that a javascript object StackExchange is defined on any stackexchange site.
If you just want to scrape that link in your question, you can go there in your browser, and type this in your console: $('.gv-item-collapsed-wrapper h2').text()
That page already has jQuery loaded, which you can use to search through elements on the page. That code snippet will show you all the site titles in a string.
Better yet (but a little more complex)
var arr = [];
$('.gv-item-collapsed-wrapper h2').each(function(){arr.push($(this).text())});

I just tested a small portion of the sites, and this seems to work:
window["StackExchange"] !== undefined
If you look at the source of any page, there is always something like this:
StackExchange.ready(function () {
So basically you're checking to see if that class, StackExchange exists, and if it does, most likely (I'm sure in the masses of the internet, somebody is borrowing/stealing the code or using the same name) a StackExchange site.

Related

How to make next page link when document size reaches to specific length? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have built an Admin section where i can see all the contents from database in a table. everything is fine but if the database table has thousands of rows I have to scroll down very deep. is there any way I can make links like `1,2,3.Next the way google search results do? or is there any even better way?
Isn't is going to be something like:
if($(document).height>2000){
//what should i do?
}
Looks like you are using jquery. If you are going to implement everything on your own it may be time consuming - although it would be fun!
To save some time, there are quite a few plugins available to achieve this. Refer:
https://datatables.net/
http://www.jqueryscript.net/table/Client-side-HTML-Table-Pagination-Plugin-with-jQuery-Paging.html
Since you may have huge data you should be using server side pagination instead of client side. Here is another SO link which explains the difference between them : Pagination: Server Side or Client Side?

How to show client the prototype without using a server for a web site [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have created a webpage that takes a skill survey of students of a particular college but they are not ready to give me server yet they would want to see the prototype first how to show them the prototype without using the server but just using the web page that I have created?
A prototype shows how it works without actually working. So instead of getting real data, it can show fake data.
Your survey can show just two or three questions, and these questions can be hard-coded or loaded from a mock object, instead of loaded from the server. Also, instead of actually saving anything, it can just jump to the next question and show a text saying 'Thanks' when you are done.
That way, you can see if your survey has the right look and feel, and they can see that too. Also, it may make it a bit more clear to the server-builders what kind of implementation they need to make. A visible, 'clickable' prototype makes it easier to discuss details in the implementation.

Classroom assessment tool [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I want to create an HTML file which pulls information from one of several possible databases.
The database will consist of students names and target grades and there will be one for each class.
The page created will effectively have a block/button for each student with a drop down box which contains a grade.
I would like to send this data to another database (one for each class) to track progress over time, effectively when submitting the classes grades I want to add a coloumn to the database
I have been learning programming for the last 12 months and have a reasonable understanding of HTML, JavaScript, Python (I have also just started leanring some jquery) . I dont want a full fledged solution but if someone could point me in the right direction I would be happy to do the hard work.
Primary question is what language do I need to learn to code read and write to the database? Any other suggestions about scripting are more than welcome.
I would use PHP and Javascript (jQuery is a easy to use framework). PHP can handle the "backend" operations like reading and writing to the database. HTML / CSS / Javascript can handle the view.
If you want to do all of this without the annoying page refreshes you can take a look at AJAX.
Some links to help you getting started
http://www.php.net/manual/en/getting-started.php
http://learn.jquery.com/javascript-101/getting-started/

How to get the data I need from airbnb web page? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to get the dates booked and price from the the airbnb page: https://www.airbnb.com.sg/rooms/2781352 under the "Calendar" tab of it.
I am quite newbie to this, and I want to python to do that, can I?
And what else should learn, javascript, PHP?
For extracting data from web pages, my first stop is Beautifulsoup. It is designed for just this purpose, and is excellent at it. Combine it with the great requests HTTP library (so much better and easier than urllib/urllib2/etc.) for getting the pages.
Both of these are Python modules, there is no need to learn any other programming languages to do it, although it greatly helps to have an understanding of HTML and DTDs (Document Type Definitions) for setting up paths.

How can I make an online Book like http://www.20thingsilearned.com/ [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Recently, I have found this site made by Google Team.
http://www.20thingsilearned.com/
So far I understand this is not based on Flash. How can I use this technology to make an online book using their technology?
I looked in the usual spots to see if there's a framework or something but I only found these two things (it looks like it would be a TON of work to use):
news.ycombinator.com/item?id=1918551 >>> gist.github.com/705761
Alternatively you might want to look into the slides at http://slides.html5rocks.com.
They have a Google Code project page at code.google.com/p/html5rocks/wiki/Slides where you can download the source for that.
EDIT
check this out!
http://bartaz.github.com/impress.js
and this!
http://lab.hakim.se/reveal-js/
This is HTML5. You can check the explanation here: http://www.html5rocks.com/tutorials/casestudies/20things_pageflip.html :)
Or if you want you can do it with jQuery Booklet too though not as smooth as HTML5, see here: http://tympanus.net/Tutorials/MoleskineNotebook/
They posted the source code for the whole app (running on Google App Engine) under GPL v2 at http://code.google.com/p/20thingsilearned/ so you can reproduce the whole book effect too.
Yes this is not flash for sure but flash or flexx can also be used for developing this. This is developed using HMTL 5 and javascript. HTML 5 is having a canvas object and the i believe it is using properties of canvas to bulid it. However if you will search for some jQuery book plugins then also you may get some similiar results.

Categories