How can we fetch the QnA Pair from the URL which runs JS and then renders the DOM? The file is in markdown format and renders into HTML via running JS.
I came to know that the QnA Maker only searches the HTML contents. I want to have QnA pairs from a markdown file. For example:
This works in QnA: https://github.com/gulpjs/gulp/blob/master/docs/FAQ.md
While this not: https://raw.githubusercontent.com/gulpjs/gulp/master/docs/FAQ.md
I am able to get the content as a second one from a page, but it's of no use as QnA doesn't support raw markdown. It supports in the form of HTML and the page I am requesting renders it after running JS.
I tried requesting with Postman too and body only contains Please enable JS and the same is happening with QnA.
Related
I am making a module that converts html to json in node environment. I would like to know how to access web browser api from node. How can I access document object with nodejs only without libraries such as cheerio and jsdom?
(I used Google Translate, sorry)
Node.js does not have built-in support for rendering HTML documents.
It doesn't execute JavaScript that it extracts from <script> elements inside an HTML document.
It has no native document object.
If you want one you either need to build it yourself or use a third-party library.
I use my Azure function to return a certain output after passing an HTML trigger. The webpage prints out basic output, like Hello {name}.
I would like to pass this output into an HTML file and display it via a separate HTML file. Essentially, I want to extract what my helloworld.azureapp.com?name={name} returns and push it into a JS variable in an HTML file.
How would I do this?
Note that the Azure function is written in Python.
If I understand correctly, what you're looking for is to make your web application send a GET request to your azure function endpoint and store the response you get back in a javascript variable.
You should treat the responses from an Azure function HTTP trigger just like any standard response from any API.
Instead of writing all js code in native HTML files, it is recommended you pick a simple web application framework.
For python, you can try Django or Flask (introductory tutorials here).
The code that calls your Azure function endpoint helloworld.azureapp.com?name={name}
could be in your web application (using the requests module in python). Tutorial on how to make web requests in python here.
Once you get back the response for that request, you can do further processing with the values you get back.
Depending on your web application framework, you could do many things.
Some of them are:
Save it in a hidden field and get value in JavaScript.
Render the received values to element in page on server side and show it.
I am running a website on an Ubuntu server with mongodb as database that is purely written in Nodejs. The app runs on a server and all the requested route to ejs files. Inside the entry ejs file of the site I used tags with description about the site, however, still after a couple of days nothing from google is indexed. In generally, how should we let google index ejs pages particularly when there is not any html files.
Does not matter which view engine (razor, ejs, pug) you are using since all of them renders HTML as final result. So don't care about ejs.
Google takes some time to index content. According to this you can ask Google to (re)index.
We are currently trying swiftype and wanted to see how to Crawl our website that has javascript frameworks becauase there are async calls.
I created a engine and was able to run a crawl based my sitemap, but instead of reading the actual content, it is reading my Angular js code.
For eg:
if have an angular code something like
<div ng-class='grey title'> {{ctrl.title}}</div>
and if this data gets binded on page load, instead of reading the title, it reads the actual code as {{ctrl.title}}
so when i search, the page returns something like
"This article is about {{ctrl.title}} . We take you through.... "
Any idea on how to make it compatible with js frameworks?
You can use a "headless" browser through i.e. Playwright.dev. "Headless" means it doesn't have a GUI. Since it's actually a browser it'll interpret the page correctly. It can be started from a JavaScript that runs server-side. Check out Web Scraping : Handling AJAX website part I and the code on GitHub: introWebScraping.
I am using nodejs server to serve static files. When the pdf file is served, the browser displays the title as URL of the pdf path.
127.0.0.1:8080/docs/sample
How can I set this to a custom title say "Sample"
I have tried following things but no luck :
res.setHeader('Content-Disposition', 'inline;filename="sample.pdf"');
Setting meta tag of pdf file as "sample"
Any help will be much appreciated.
If you're using a static file server, then yes you are serving it as a download. Modern browsers often contain a built-in PDF viewing plugin, so instead of asking the user where to save the file, the browser will instead just display the PDF right in a browser tab. It still downloaded it, it just saved it to some temporary cache on your machine in that case.
What I'm getting at is that you cannot control the browser title in that case because it's just the browser trying to be nice and make things convenient for the user. The PDF file itself would have no idea if it was being displayed in the browser's built-in viewer or in Adobe Reader on the desktop. There are no HTTP headers you could send down to set the title either because browsers expect page titles to be set from HTML or JavaScript running on an actual web page.
Now, if you were to embed the PDF file in an HTML page with some kind of PDF viewer then you could control the page title with a simple <title>some title</title> tag or calling document.title = 'some title'; from JavaScript. That works because the browser is rendering an actual web page that you control, and that page just happens to have an embedded PDF viewer on it.
Here's an example of an embeddable PDF viewer. http://pdfobject.com/
//hack alert
You could trick the browser by setting the last fragment of the url to whatever you like . i.e. change sample in your example to the desired title.
(tested in chrome 58.0.3029.110)
HTH