Unable to do pagination with LinkExractor - scrapy

I'm trying to pagination, I've used my method which is working fine but I want to use LinkExtractor function to do the task.
The only problem is problem is that link in a tag is not complete.
Next<span class="a-letter-space"></span><span class="a-letter-space"></span>→
rules = (Rule(LinkExtractor(allow='Next'), callback='parse', follow=True ),)
As you can see the code, how can I add https://www.amazon.co.uk/ in the start of that rule.

The problem is allow='Next', it doesn’t do what you think it does.
I think you are looking for restrict_text='Next' instead.
Check the LinkExtractor documentation for a full list of supported parameters.

Related

Minecraft Spigot I cannot get String from Component

Hello Support I can't get the String from a Component. I did this with 2 ways with bad results.
TextComponent textComponent = (TextComponent) item.displayname;
return textComponent.content();
The result of this is a error with Casting
and
return PlainTextComponentSerializer.plainText().serialize(item.displayname);
The result of this is Literaly "chat.square_brackets" which is weird.
Please Help. Thanks
I also was having trouble with this. Here's what I found to work for me. Full disclosure that I'm developing my plugin on the PaperMC 1.16 fork and not Spigot. So it's possible that this may not work for you, either because it isn't a part of Spigot or because you are working in a version that this feature is not a part of.
To start, I would first check to make sure that we are both on the same page. For me, the component objects being used are from a package called net.kyori.adventure.text if yours are not provided by this package I don't know that this solution will work for you.
Also as mentioned by others, accessing the displayName directly on the ItemStack isn't going to give the desired results. Instead, you need to do itemStack.getItemMeta().displayName(). This method should then return a net.kyori.adventure.text.Component; once you have the component you need to serialize it using one of the serializers from the previously mentioned package.
That will look something like this:
Component itemDisplayName = itemStack.getItemMeta().displayName()
PlainComponentSerializer plainSerializer = PlainComponentSerializer.plain();
String itemName = plainSerializer.serialize(itemDisplayName);
The package that the serializer is from is: net.kyori.adventure.text.serializer.plain.PlainComponentSerializer
I don't understand how you can access to the displayname field in ItemStack in the Spigot API.
You should use ItemMeta to manage display name. To get the item meta, you should use ItemStack#getItemMeta.
Don't forget to check if the item as a meta with hasItemMeta. You can also use hasDisplayName to be sure that the display name is valid.

Is using Javascript in odoo.fields.HTML possible?

I want to integrate Adobe Captivate Content (Export: index.html, along with src-folder) into ODOO Community Edition v13 e-Learning Module (website_slides).
The slide.slide model already offers slide_type 'webpage' alongside the field 'html_content'.
The field 'html_content' is of type odoo.fields.HTML. To get the requirement stated above to work, I need to embed Javascript in the given html_content. It seems like the JS-scripts are not working. I also tried with a simple Hello World script.
Can someone help?
Best regards,
Lars
I found the solution already.
Looking at odoo/fields.py -> class Html, you can see that by default the given value is being sanitized using odoo/tools/mail.py -> html_sanitize(), which removes the HTML-Elements in 'tags_to_kill'. 'tags_to_kill' also contains "script".
After overriding html_content in slide.slide with the following, the Javascript-code is being executed:
html_content = fields.Html(
sanitize=False,
sanitize_tags=False,
sanitize_attributes=False)

API: Absolute URL

So I have this bit as a part of the a code that came with the html template that I purchased. I was told that in order for this to work, I need to use the absolute URL of 'api/tweet.php'.
This is all I one line:
(function($){$.fn.twittie=function(options){var settings=$.extend({'count':10,'hideReplies':false,'dateFormat':'%b/%d/%Y','template':'{{date}} - {{tweet}}'},options);var linking=function(tweet){var parts=tweet.split(' ');var twit='';for(var i=0,len=parts.length;i<len;i++){var text=parts[i];var link="https://twitter.com/#!/";if(text.indexOf('#')!==-1){text=''+text+''}if(text.indexOf('#')!==-1){text=''+text+''}if(text.indexOf('http://')!==-1){text=''+text+''}twit+=text+' '}return twit};var dating=function(twt_date){var time=twt_date.split(' ');twt_date=new Date(Date.parse(time[1]+' '+time[2]+', '+time[5]+' '+time[3]+' UTC'));var months=['January','February','March','April','May','June','July','August','September','October','November','December'];var _date={'%d':twt_date.getDate(),'%m':twt_date.getMonth()+1,'%b':months[twt_date.getMonth()].substr(0,3),'%B':months[twt_date.getMonth()],'%y':String(twt_date.getFullYear()).slice(-2),'%Y':twt_date.getFullYear()};var date=settings.dateFormat;var format=settings.dateFormat.match(/%[dmbByY]/g);for(var i=0,len=format.length;i<len;i++){date=date.replace(format[i],_date[format[i]])}return date};var templating=function(data){var temp=settings.template;var temp_variables=['date','tweet','avatar'];for(var i=0,len=temp_variables.length;i<len;i++){temp=temp.replace(new RegExp('{{'+temp_variables[i]+'}}','gi'),data[temp_variables[i]])}return temp};this.html('<span>Loading...</span>');var that=this;$.getJSON('api/tweet.php',{count:settings.count,exclude_replies:settings.hideReplies},function(twt){that.find('span').fadeOut('fast',function(){that.html('<ul></ul>');for(var i=0;i<settings.count;i++){if(twt[i]){var temp_data={date:dating(twt[i].created_at),tweet:linking(twt[i].text),avatar:'<img src="'+twt[i].user.profile_image_url+'" />'};that.find('ul').append('<li>'+templating(temp_data)+'</li>')}else{break}}})})}})(jQuery);
Does anyone know how to use or get the absolute URL of tweet.php? I've tried researching or doing a google search on it but none seem to work.
The location of the tweet.php is
http://exampledomain.com/api/tweet.php
EDIT:
This is the thread discussion that I posted on their support website. I didn't share the link since it requires visitors to open an account with them just to view responses
Support Thread Picture
According to the Tweetie jQuery plugin documentation, you have to use the apiPath option:
$('.foo').twittie({
'apiPath': 'http://exampledomain.com/api/tweet.php',
});
But specifying the domain is discouraged and unnecessary. So :
$('.foo').twittie({
'apiPath': '/api/tweet.php',
});

How do I use inline templates in MODx Revo?

I'm using the Login snippet in MODx Revo and I'm trying to put the template directly in the loginTpl and logoutTpl properties but nothing is being output. Below is my code. What am I doing wrong?
Thanks in advance!
[[!Login? &tplType=`inline` &loginTpl=`<span>Log In</span>` &logoutTpl=`<span>[[+username]]</span>`]]
The placeholders are evaluated before snippet is processed, i.e. before the #INLINE tpl is ever used.
Use chunks;
Or non-cacheable placeholder (has not been tested):
[[!Login? &tplType=`inline` &loginTpl=`<span>Log In</span>` &logoutTpl=`<span>[[!+username]]</span>`]]
It fully works, check to see if login component is installed (it is not installed by default).

Ruby on Rails routing: how to remove (using redirection) a URL prefix

I'm sure this is dead simple, which is why I'm so annoyed...
The problem originated from using translate_routes. This is very simple to use and presents no problem whatsoever. All I want is to be able to have the default locale prefix in the url, optionally.
Right now, I can do:
GET /controller/ and
GET /fr/controlleur/, but trying
GET /en/controller/ fails.
I figured that the en in the last example is not useful, so I want to 'remove' it using redirection. However, all my attempts up till now have failed.
How can I remove that prefix?
match "/en/*path" => redirect("/%{path}")
http://guides.rubyonrails.org/routing.html#redirection
http://guides.rubyonrails.org/routing.html#route-globbing