ngMeta | Dynamic meta tags in your AngularJS single page | Search Engine Optimization library
kandi X-RAY | ngMeta Summary
kandi X-RAY | ngMeta Summary
Dynamic meta tags in your AngularJS single page application. This is an Angular 1.x module. Angular2 module is available as ng2-meta.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Initializes the MetaPage .
- Helper function to set NgMeta .
ngMeta Key Features
ngMeta Examples and Code Snippets
Community Discussions
Trending Discussions on ngMeta
QUESTION
I want to download Apollo images from Nasa website using requests module in Python.
This is my beginning code-
...ANSWER
Answered 2020-Jun-24 at 09:07When you make an HTTP GET request to https://images.nasa.gov/search-results?q=Apollo
using the requests
module, you get back exactly the resource you requested from the server: that HTML file. Nothing else. When you make the same request with a browser, the browser knows to parse that HTML file to execute scripts, make ajax requests / XHR requests, make requests based on meta data / links / stylesheets in the HTML, etc. It's this action by the browser that completely renders a given page the way it's meant to be seen by human eyes. When you make a simple HTTP GET request to a page, like what you're doing, you just get back the barebones template, where the DOM hasn't been populated yet, since this is typically meant to happen asynchronously at a later point in time.
You can still use the requests
module, but you'll just use it differently: Instead of making an HTTP GET request to a webpage, you make an HTTP GET request to NASAs RESTful image asset API, which is the same API your browser makes requests to when populating the page. This is ideal because you won't have to scrape a page using BeautifulSoup or anything like that, you just imitate the same request your browser would make, and you get back JSON:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ngMeta
Add ngMeta as a dependency of your module. ngMeta supports ui-router and ngRoute. Add meta objects to your routes (ngRoute) or states (ui-router) and specify the meta tags appropriate to each view. Other than title and titleSuffix, which are reserved properties that affect the title of the page, the tag properties can be named as per your choice. [Optional] Set the default values of meta tags during Angular's configuration phase. If the meta object of a route does not contain a specific tag, the default value is used instead. Let ngMeta initialize by calling the init() function in the app.js run block. Set the meta tags in your HTML file.
Add ngMeta as a dependency of your module. ngMeta supports ui-router and ngRoute. angular.module('YourApp',['ngMeta']);
Add meta objects to your routes (ngRoute) or states (ui-router) and specify the meta tags appropriate to each view. Other than title and titleSuffix, which are reserved properties that affect the title of the page, the tag properties can be named as per your choice. .config(function ($routeProvider, ngMetaProvider) { $routeProvider .when('/home', { templateUrl: 'home-template.html', data: { meta: { 'title': 'Home page', 'description': 'This is the description shown in Google search results' } } }) .when('/login', { templateUrl: 'login-template.html', data: { meta: { 'title': 'Login page', 'titleSuffix': ' | Login to YourSiteName', 'description': 'Login to the site' } } }); ... });
[Optional] Set the default values of meta tags during Angular's configuration phase. If the meta object of a route does not contain a specific tag, the default value is used instead. //Add a suffix to all page titles ngMetaProvider.useTitleSuffix(true); // On /home, the title would change to // 'Home Page | Best Website on the Internet!' ngMetaProvider.setDefaultTitleSuffix(' | Best Website on the Internet!'); //Set defaults for arbitrary tags // Default author name ngMetaProvider.setDefaultTag('author', 'John Smith');
Let ngMeta initialize by calling the init() function in the app.js run block angular.module('YourApp', ['ngRoute', 'ngMeta']) .config(function($routeProvider, ngMetaProvider) { .... }) .run(['ngMeta', function(ngMeta) { ngMeta.init(); }]);
Set the meta tags in your HTML file <title ng-bind="ngMeta.title"></title> <!-- Arbitrary tags --> <meta property="og:type" content="{{ngMeta['og:type']}}" /> <meta property="og:locale" content="{{ngMeta['og:locale']}}" /> <meta name="author" content="{{ngMeta['author']}}" /> <!-- OR <meta name="author" content="{{ngMeta.author}}" /> --> <meta name="description" content="{{ngMeta.description}}" />
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page