How to check which part of page is an article? [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 would like to create a similar tool to Instapaper or Readability and I wonder what is the best way to find and get text from a web page. Do you have any ideas?

The question is too broad to give a concrete answer to, but you can separate this question into three concerns:
A way to grab web resources. libcurl for example, or just about anything able to talk HTTP.
A DOM parser. Python has xml.dom.minidom, for example.
An algorithm for traversing the DOM tree and extracting text. Be it scanning for elements with class=article, or <div>s with more than 1024 characters etc., is entirely up to you. You will need experimentation to get this right.
I suggest asking separate questions for each of these concerns. After doing research on each, of course. :)

Here is an idea to get you started in Ruby. Just tested the code below and it is working fine for me. Have a look it might help you.
require 'open-uri'
require 'cgi'
require 'nokogiri'
$url='http://www.stackoverflow.com'
$txt_file = open($url)
$raw_contents = $txt_file.read
$html = Nokogiri::HTML(CGI.unescapeHTML($raw_contents)).content
#strip the web page fetched out of all hmtl tags and encoded chars
$txt_file = File.new('c:\ruby193\bin\web-content\stack.txt', "w")
#stack.txt now contains a stripped, pure txt file which you can manipulate further
$txt_file.write($html)
$txt_file.close
puts 'Here is the stripped text of your webpage\n'+$html

Related

questions about php and node.js with answers [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 1 year ago.
Improve this question
I'm working with PHP and I love this language but when I look at big websites there a small percentage of them using PHP and the rest of using node.js etc, so based on the big websites like Netflix, etc, have some questions
1- Is PHP required in companies?
2- what PHP framework should I learn
3- what frontend framework, etc, good for PHP?
4- is node.js better than PHP
if there is anything wrong or you can correct me I'm here to learn :)
I'm very lost I really need the answer I don't know where to go.
in PHP there is no way to automatically refresh the page however
there is a guide on this page to do that
if you started to use a framework like Laravel you can do that with
the Browsersync plugin
I have seen a lot of PHP and Laravel projects requests in freelancing
websites than node js so yes it's required
both languages are needed there is no language better than the other
one each one have its use cases

Language change on website best way [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 1 year ago.
Improve this question
I am making a website where I need to include a language change button from Hungarian to English.
Now my question is which is the best way to do that.
I mean should I just make new HTML files with different language or is there a better way to do it. I found some solution with Javascript but they used blocks which is not good for me because I have to change a lot of texts and some PHP solution but I have never used PHP yet.
Best would be a solution with Javascript or Node.js or something that I can learn fast :D
Dump all the content of the page to a string or some data structure and then by using the module "translate" you can translate it to any other language. It provides translation to multiple languages then on button click translate the text and send back as response and set the text on the client side. You can install it by:-
npm install --save translate
A sample code for that will be:-
// 'es' can be a language string or an object like { to: 'es' }
translate('Hello world', 'es').then(text => {
console.log(text); // Hola mundo
});
You can find more help here:-
https://www.npmjs.com/package/translate

convert to PDF from html or svg, which one is best? [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 5 years ago.
Improve this question
I am going to work on some project where i need to create PDF of some sections in webpage...
Its completely in decision phase what should do for it...
So i have found that we can convert HTML to PDF using some js OR other lib which work at server end...same i found for SVG images...
But confusion is like some time info found as HTML to PDF is good idea whereas few says SVG to PDF will be good for you to maintain Quality etc...
So I wan views with experience that which is best way to go with?
If you need to create a PDF of a webpage then you'll have to convert from HTML to PDF. You cannot convert from SVG to PDF because simply you don't have the SVG - which is a vectorial image format - to start with. Then the question is not whichever it's the best, it's which is the most appropriate for your use case.
Note that HTML describes the structure of a document, not its style (this can be done via CSS) and hence not the way it appears.

What is the most optimal way to work with database + javascript in terms of performance? [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
Context : I would prefer to work with Javascript with a database (pref mySQL) to create a new website.
I did a quick search, and one option would be to have PHP + JS + HTML.
However, isn't PHP kind of "old"/"slow" now ?
One other option would be to use Node.js (not really comfortable with it).
Any comments ? Is PHP + JS + HTML still viable?
Thanks!
Yes it is viable and it is widely used. Where did you get that PHP is kinda slow now? And what is the problem being old? Being old is more reliable and more useful as many users are contributing documentations and samples on how it's being used.
Slowness depends on your server's hardware specifications, your MySQL queries and code structure. I don't think that PHP will slow down your business needs because it's reliable and widely used by many companies. Being open source is a great advantage too.

Is creating html content using javascript is a good or bad [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 9 years ago.
Improve this question
I have seen in one of web application, they are creating entire dashboard HTML content using JavaScript methods, Why they are doing this ? by using JavaScript it will take much time to generate HTML tag and hard to debug and edit.
can someone explain what is advantage and disadvantage of using it ?
eg.
var ntfytab = new com.xyz.HTM('table',ntfy).init({width:'100%',id:"myTable02"});
var ntfyhad = new com.xyz.HTM('thead',ntfytab).init({});
new com.xyz.HTM('tr',ntfyhad).init({inner : new com.xyz.HTM('th',null)
.init({inner : 'Message'})});
If it is needed then it is ok, because almost all of the javascript libraries (jquery, prototype etc) plugins generate html in their code to be inserted in the page.
It is not a problem, it is just difficult and complex to understand :P
Disadvantage is the search engines dont read javascript.
There are lots of advantages. For example if you need to generate and display some html based on some conditions, some events etc then you can do it in javascript.
Think about image sliders, javascript based text editors and other animations effects based on javascript.
Creating tags by Javascript are not rendered by search engines... Or, they may have some sort of privacy control/check so that, no one(lay man) can copy their code..
It can be a suitable solution to output dynamic interfaces, eg tables where the number of rows etc may vary considerably (to output data received via ajax for example).
i would recommend only to create HTML by JS for dynamic content.
for static content alsways use your HTML files which are rendered before JS code will be executed!

Categories

Resources