getting URL of pages with ajax - html

This is a webpage with a number of "subpages" embedded in ajax for all the user reviews.
http://www.goodreads.com/book/show/13636400-the-bone-season#
I am trying to get the specific URL for particular pages (say ?page=4), so I can point people to particular reviews directly instead of going to the page and clicking on page4. below is a snippet from the source code for that page:
<a href="#" onclick="new Ajax.Request('/book/reviews/13636400-the-bone-season?page=4', {asynchronous:true, evalScripts:true, method:'get', parameters:'authenticity_token=' + encodeURIComponent('XsOgyhAC4p0tAm8wGIqTQGY+PxGpDieI45AYry0NlE4=')}); return false;">
when i type http://www.goodreads.com/book/reviews/13636400-the-bone-season?page=4, i get a blank page.
What do I need to do get the page to show? Thank you!

You can get the url for the specific reviews, but I was unable to find anyway to do so for the "page". If you want to direct someone to a specific review, then you can get that url from the "see review" link or the date link on that particular review.

New answer: you need to submit a GET request (using cURL for example) with the parameter mentioned ('authenticity_token=' + encodeURIComponent('XsOgyhAC4p0tAm8wGIqTQGY+PxGpDieI45AYry0NlE4='), and parse what is sent back. Then you'll get your review. Linking to it is not possible unless you find a URL where your review is always displayed.

Related

How can I differentiate between two url requests from different HTML pages but with the same namespace in views.py?

I am creating a simple eBay like e-commerce website to get introduced with django. For removing an item from the watchlist, I placed two same links in two different HTML files, that is, I can either remove the item from the watchlist.html page or either from the item's page which was saved as listing.html. The url for both the pages look like this:
Remove from watchlist
Now, in my views.py, I want to render different pages on the basis of the request. For example, if someone clicked Remove from watchlist from listing.html then the link should redirect again to listing.html and same goes for the watchlist.html.
I tried using request.resolver_match.view_name but this gave me 'removeFromWatchlist' as the url namespace for both of these request is same.
Is there any way I can render two different HTML pages based on the origin of the url request?
Also, this is my second question here so apologies for incorrect or bad formatting.
You could check the HTTP_REFERER in the request.META attribute of the view to get the url that referred the request as so:
from django.shortcuts import redirect
def myview(request):
...
return redirect(request.META.get("HTTP_REFERER"))#Or however you prefer redirecting
https://docs.djangoproject.com/en/3.1/ref/request-response/#django.http.HttpRequest.META

href whatsapp link to number

I'm having an issue trying to send Whatsapp messagges through browser using this code:
click
Using this code, Whatsapp opens correctly but the number is not recognized (i'm trying with my number, which is registered in Whatsapp) saying something like "You're trying to reach a non-Whatsapp number. Invite him or send SMS".
My international code (Italy) is +39.
I've tried 003912345, +3912345, 3912345, 12345, but with no success.
Anyone experienced this? Thanks for the help!
You get the message"You're trying to reach a non-Whatsapp number. Invite him or send SMS" because the number you want to use for sending the message to must be present into your phone contact list.
Anyway the attached code you use for the link won't work on iOS.
Try to use: href="whatsapp://send/?text=<>" data-action="share/whatsapp/share" . The link will open WhatsApp but you will have to manually select the consignee of the message from your contact list, otherwise you could use the ABID code to send the message directly to your contact.
Here you'll find more info about this technique: https://www.macstories.net/tutorials/use-whatsapps-url-scheme-with-drafts-launch-center-pro-or-a-bookmarklet/

retrieving URLs from functions within HTML (python)

I need to scrape some URLs from some retailer product pages, but the specific URLs I need to get aren't in the html part of the page. The html looks like this for each of the items on which one would click to get to the page with the URL I need to grab:
<div id="name" class="hand bold" onclick="AVON.productcontrol.Go(45714);">ADVANCE TECHNIQUES Color Protection Conditioner Bonus Size</div>
I wrote the following to get URLs from the page, but since the actual URLs I need don’t seem to be stored in the page, it doesn’t get what I need:
def getUrls(URL):
"""input: product page url
output: list of urls to products
"""
connection = urllib.urlopen(URL)
dom = lxml.html.fromstring(connection.read())
selAnchor = CSSSelector('a')
foundElements = selAnchor(dom)
urlList = [e.get('href') for e in foundElements]
return urlList
Is there a way to get the link that the function after ‘onclick’ (I guess AVON.productcontrol.Go(#);) takes you to? I don’t fully understand html, and while I’ve read a bit about onclick, I can’t figure out how the function after 'onclick' works.
In order to find the URL that you are taken to on click, you need to find the JavaScript source code of the 'Go' function and read and understand it. It's buried somewhere within a tag or some JavaScript .js file that is referenced directly or indirectly by the HTML page. Happy digging!
Or: you automate the interaction with the web page with a tool like Selenium (http://docs.seleniumhq.org/) and just check where it takes you if you click.

How to determine what content is active on a page

I am at a bit of loss of knowledge and honestly don't know what to search for. What I need to be able to do is determine what content to show on a webpage that way when I refresh it will not reset everything. For example, if someone clicks on the messages tab I want the browser to know when it refreshes, that is the tab to stay on. I believe this is done through url encoding but I am not sure. Any help would be AWESOME! Thanks fellow coders.
MORE INFO: I have 2 buttons on a page. One is named "home" and when I click it I want the content of the home page to appear in a box named "info-main". I am doing this with ajax requests. When I click on "edit profile", I want the content in div id "info-main" to be replaced with the edit profile information that is retrieved via ajax as well. I need to figure out how if someone refreshes the page... I want it to stay showing the edit profile information rather then going back to the default of "home" content.
MORE INFO(AGAIN)
I just had a great idea. When the page refreshes, I want it to load specific ajax code based on what the url encode is.
For example.... if the url is:
http://www.exampleurl.com/index.php?info=status-load
I want the browser to execute the ajax I have for retrieving status's.
OR
If the url is:
http://www.exampleurl.com/index.php?info=edit-prof
I want it to load the ajax code I have for retrieving profile edit info.
I really hope this helps. :/
The way I do it is I place a # before the link i.e. href="#messages"
Then I link a .js with this code.
$(function () {
var hash = location.hash
, hashPieces = hash.split('?')
, activeTab = $('[href=' + hashPieces[0] + ']');
activeTab && activeTab.tab('show');
});
I hope this helps
For referring an element on your page, you use a link with a hashtag.
For example, if you have a layout like this:
<div class="top-nav">
Home
Edit Profile
</div>
And you have a password edit form on your editProfile page, you can like to it like this:
Edit Profile
if you have a <form id="passwordChange"> on your editProfile.
Read more: http://css-tricks.com/hash-tag-links-padding/

FB Share without App ID

Is it possible to use FB share plugin without APP ID?
If I use HTML5 code then the console logs an error FB.getLoginStatus() called before calling FB.init().
To use HTML 5 FB like is it necessary to have an APP ID?
Thank you
Here i am sharing what i did to share post on fb wall, In this way you do not need to use appId. Just put this code in your HTML page where you want link to share...
<a name="fb_share" type="button" href="http://www.facebook.com/sharer.php?u={$url}&media={$imgPath}&description={$desc}" class="joinFB">Share Your Advertise</a>
URL parameters are as explained below,
u : url or link you want to user to go when he clicks on your wall post,
media : full image path,make sure that image is available on given path,it will accept one image only
description : a short description that you want to show on wall
It will also ask you to write some data which will be displayed above your post. Description passed in url will be displayed in right side of your image.
Please note that i had passed $url,$desc,$imgPath variables as per my need. The above code is in smarty-php, so change it as per your requirement.
Hope this becomes helpful to you.
Yes you need an app id. You can try to inject your own code into the DOM of the user when using facebook and call functions in their javascript... But I doubt many users will actiually use an "app" that works this way.