Node.js + Express.js. Google shows me the server side translation IDs - node.js

I have a very strange problem with a webpage I made with Node.js + Express.js.
My webpage is multilanguage (English/Spanish), so in the Jade templates I have translations IDs which correspond to a text depending on the selected language. Ok, that works well.
Now, when I search the webpage in Google, it appears on the first result without problems, but in the description it shows me the translation IDs, not the rendered text. It's very strange because the translation is supposed to be made on the server side, isn't it?

The problem seems to be that there isn't a default language and Google's web crawlers don't seem to specify a preference.
The i18n seems to be reasonably based on the Accept-Language request header:
curl --header 'Accept-Language: en-US,en' http://www.porcupinee.net
<div id="why" class="row">
<h2>Why should you choose us?</h2>
<h3 class="text-center">We are young developers focused to the web</h3>
<!-- ... -->
curl --header 'Accept-Language: es' http://www.porcupinee.net
<div id="why" class="row">
<h2>¿Por qué debería elegirnos?</h2>
<h3 class="text-center">Somos jóvenes desarrolladores enfocados a la web</h3>
<!-- ... -->
But, no substitution is performed without that header or when another language is specified:
curl http://www.porcupinee.net
curl --header 'Accept-Language: de' http://www.porcupinee.net
<div id="why" class="row">
<h2>why.title</h2>
<h3 class="text-center">why.we.title</h3>
<!-- ... -->

Related

Nodejs writing a scraper that can read JS protected websites

nodejs is new for me, and I've just started learning web scrapers. The problem is that I need to scrap a website that is protected with JS. So I need to get phones from the website, but div with the phone number appears only after user clicks on "show number" button. Are there any ways or npm to get the numbers? Here is the website enter link description here, but it is in russian language. So the button is "показать телефоны". Thank you in advance!
Go to the page with the phone numbers and open the console and look at your network tools. When you click on a phone number it makes an ajax request and gives you a nice formatted response
{"status":"ok","phone":"+7 (727) 317-20-86","html_tooltip":"<section class=\"company-phones-tooltip\">\r\n <div class=\"company-phones-tooltip__wrap\">\r\n <header class=\"company-phones-tooltip__header\">\r\n Inform the manager that you learned the information on Allbiz.\r\n <\/header>\r\n <ul class=\"company-phones-tooltip-list\">\r\n <li class=\"company-phones-tooltip-list__item\">\r\n <div class=\"company-phones-tooltip-list__name\">\r\n management\r\n <\/div>\r\n <div class=\"company-phones-tooltip-list__number\">\r\n +7 (727) 317-20-86\r\n <\/div>\r\n <\/li>\r\n <\/ul>\r\n <footer class=\"company-phones-tooltip__footer\">\r\n <a class=\"company-phones-tooltip__link\" href=\"https:\/\/12246-kz.all.biz\/contacts\" target=\"_blank\">\r\n Show all contacts\r\n <\/a>\r\n <\/footer>\r\n <\/div>\r\n<\/section>"}
In order to emulate this you just need to make a call to the http://api.all.biz/ajax/viewphonenew/kz endpoint with the correct parameters after scraping the page. And all the query params that are needed for this endpoint is in the html element.
<div class="company-phones__wrap" data-click="company-phones" data-entid="58474" data-verify="bYjmFpAfm5QWOgIjx8cyNOARdSG3FIoPo6he2dYGLIc=" data-phone="Zk6xDyCXPMqWMXgTaCI51A24FHIsDwuy8IaF993LsHI=" data-country="kz" data-placement="company-phones-tooltip___3" data-tooltip-direction="left" data-source="list">
<div class="company-phones__code">+7(7 </div>
<div class="company-phones__main" data-ga="show-phones-list" data-ga-id="">
<div class="company-phones__btn">Показать телефоны</div>
</div>
</div>

StripFilter in Liferay 6.1.1 GA2 doesn't strip white space

We're using the StripFilter property in our production systems:
com.liferay.portal.servlet.filters.strip.StripFilter=true
but on the most pages the markup isn't properly stripped (some parts like navigation has massive whitespaces, others like head are fine) or worst case the whole markup is not stripped!
Those non stripped pages have up to 20k lines of source code (mostly blank), which causes poor performance in browsers.
Mostly appears when pages requested as guest user, but this is not reproducible.
Also when we undeploy all webapps, this problem occurs.
How we can investigate this problem?
Is this a common issue?
If some part of the beginning of your page is actually stripped and the rest is not, then the filter tripped over your html. Maybe you have an error in your html code. Or the strip was simply too stupid.
Remember that you must (because of the filter) close input tags with a /> If you do not, the filter looks up the next /> and does not strip anything between!
Example
<input name="bla">
<p> hello world,
<br />
<span> you are </span>
beautiful. </p>
This will lead to the following output, because the closes the
<input name="bla">
<p> hello world,
<br /><span>you are</span> beautiful. </p>

Orchard CMS 1.7 - Change in header does not appear on the site. Layout.cshtml issue

I cannot figure out how to change a text in the header section of my site. I am trying to do this in my custom module's theme. This is how my header looks like:
<header>
<div class="container">
<div class="row-fluid">
<div id="Logo"><h1>#WorkContext.CurrentSite.SiteName</h1></div>
<h3>[ We Know Business ]</h3>
<a class="btn btn-navbar btn-menuh" data-parent="#collapse-nav" data-target=".collapse-menuh">btn</a>
<a class="btn btn-navbar btn-search" data-parent="#collapse-nav" data-target=".collapse-search">btn</a>
</div>
</div>
</header>
I changed [We Know Business] to [We know Businesses] but the updated text is not coming up on any page of my site.
However, my main objective is to use HTML5 and Responsive compatibility in IE8 by injecting conditional CSS and js like this:
<!--[if lt IE 9]>
<script src="/themes/intrust/js/html5shiv.js"></script>
<![endif]-->
I cannot see the above snippet in "View Source" option.
The reason I changed the text only to check whether I am doing it at the right place or not. When it didn't work I turned Shape Tracing tool on to see what template is being used for the header. But could not highlight any part of the header at all!
Isn't Layout.cshtml of my custom theme liable to render the header section? If not, which template I have to look for?
I must be doing something wrong here but cannot figure out what! Please help!
NB: I tried resetting IIS several times but had no luck either.
This is a bit late but what you are looking for is overriding document.cshtml.Orchard has a default in the folder Orchard\src\Orchard.Web\Core\Shapes\Views folder. Copy the file document.cshtml to your theme and put the items that you want in the header section of this document.

Posting data to a form cURL

I am trying to post the data to a form using curl and save it in a file , here is the form in which I want to post the data , the webpage can be accessed here form_webpage
<label for='Fldname'>Name</label></td><td>:</td><td><input type='text' name='name' id='Fldname'/>
<label for='Fldemail'>Email</label></td><td>:</td><td><input type='text' name='email' id='Fldemail'/>
<input type='password' name='x' id='Fldpwd'/>
<input type='password' name='cpwd' id='Fldcpwd'/>
<input type='radio' value='m' name='gender' id='Fldgendm'/>
<label for='Fldgendm'>Male</label> <input type='radio' value='f' name='gender' id='Fldgendf' />
<label for='Fldgendf'>Female</label>
<input type='checkbox' value='e' name='lang[]' id='Fldlange'/> Eng <input type='checkbox' value='t' name='lang[]' id='Fldlangt'/> Tel <input type='checkbox' value='h' name='lang[]' id='Fldlangh' disabled />
<select name='coun' multiple >
<option value=''>Choose Country</option>
<option value='91'>INDIA</option>
<option value='001'>USA</option>
<option value='002'>United Kingdom</option>
</select>
I have done quite a bit of research and everytime i want to post to the form it is returning the same page
I used
curl --data 'name=stirumer&email=123#gmail.com&x=test&cpwd=test&gender=m&lang[]=e&coun=91' "www.cs.odu.edu/~stirumer/index.html" -o "3.html"
curl -Gd 'name=stirumer&email=123#gmail.com&x=test&cpwd=test&gen
der=m&lang[]=e&coun=91' "www.cs.odu.edu/~stirumer/index.html" -o "3.html"
curl -X POST -F 'name=stirumer&email=123#gmail.com&x=test&cpwd=test&gender=m&lang[]=e&coun=91' www.cs.odu.edu/~stirumer/index.html -o "2.html"
curl -F 'name=stirumer&email=123#gmail.com&x=test&cpwd=test&gend
er=m&lang[]=e&coun=91' www.cs.odu.edu/~stirumer/index.html -o "1.html"
curl -X POST --data "name=stirumer&email=123#gmail.com&x=test&cpwd=test&gender=m&lang[]=e&coun=91" www.cs.odu.edu/~stirumer/index.html
All of them return the same page..!!
Expected Output
Need help guys!
Here's one way to go about this, which I've found quite useful for similar activities.
In Firefox install Firebug and Firecurl. Start Firebug, and then browse to the page in question, and submit the form. Then in the Net Panel of Firebug, look at he Firecurl output. It gives you the CURL command line for the form submission, which you can cut and paste into a shell and execute. Good way to learn what all needs to be done for any POST.
What do you expect to happen? I went to your web page and tested it and I got, what I expected to happen. When you manually go to that web page and fill in the information and click submit it just takes you back to the blank page. If you were to do the same think with curl then you'll just get the blank page back as well. I'd first make sure that your page works in a browser like you think it does.
When you use curl, it'll be like you filled in all of the form fields AND clicked submit. It's not going to just put data into the form fields and then just return you that page.

Render yesod widget

I follow the instructions here
I create a yesod project, and render a widget with defaultLayout:
You've just posted
<p>#{postedText}#{T.reverse postedText}
<hr>
<p><a href=#{MirrorR}>Get back
And here is the default-layout.hamlet:
$maybe msg <- mmsg
<div #message>#{msg}
^{widget}
<footer>
#{extraCopyright $ appExtra $ settings master}
The problem is I expect only one link to MirrorR but I got two, one is Get back,the other is the copyright in <footer>.
When you write:
<p><a ...>...
Then, Hamlet sees a free <p> tag and creates a matching </p> tag around the following content. The content that follows is assumed to be valid HTML. What is rendered is thus:
<p><a ...>...</p>
What you instead want to write is either (note that the indentation creates a new free tag):
<p>
<a ...>...
...or:
<p><a ...>...</a>
Your browser renders this as two links, because the <a> element isn't closed (and browsers go into quirks mode and enable HTML1 compatibility stuff in that case):
<p><a href="foo">link1</p>
<p>link2</p>
<!-- implicit </a> at the end of the closest block level element -->
Disclaimer: I don't have access to Yesod and can't verify this behavior; I only assume that it is like this based on the observations in the question.

Resources