I post the data in API and want to edit this data after getting from API. when I try to edit the data it gives me the following error:
CKEditorError: datacontroller-set-non-existent-root: Attempting to set data on a non-existing root. Read more: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html#error-datacontroller-set-non-existent-root
<CKEditor
editor={ClassicEditor}
onChange={this.handleChange}
data={html}
></CKEditor>
Here is the dummy solution for now, I don't know what is the proper reason of that:
Create one variable:
let a = "";
Replace the content of the variable a with the your content coming from the API
and parse it with htmlparser:
let data = a.replace("", htmlparser(/*data coming from your api*/))
Just started learning scraping and for my test project i'm trying to retreive the quantity of a certain project in scrapy shell by using
response.xpath('//script[contains("quantity")]/text()').extract()
This doesn't work.
help me understand what should be the right covention to retreive data from such attributes like quantity, category_path & etc
<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({"event":"datalayer-initialized","region":"India","account_type":"ecom","customer":{"id":""},"page_type":"Product","product":{"ffr":"csddfas","name":"tote bag by singh","materials":"100% polyester","specs":"Dimensions: 18.5\" x 6.75\"; 24L","color":null,"size":null,"upc":null,"new":false,"brand":null,"season":"HOLIDAY 2017","on_sale":false,"quantity":"158","original_price":100,"price":100,"category_path":
["Mens","Accessories","Backpacks \/ Bags"],"created":"2016-09-07","modified":"2018-02-12",
"colors":["BLACK"],"sizes":["S","M","L","XS","XL","XXL"]}});
</script>
Scrapy selectors have built-in support for regular expressions and it can help you on this case:
response.xpath('//script[contains(text(),"quantity")]/text()').re(r'"quantity":"(\d+)"')
(you need to update your xpath to collect script content since your script not good enough)
Another Way: You also can use regular expressions to collect the json content on script, parse them to json obj and work with it as easier!
You are using css method and giving it an Xpath
Try
response.xpath('//script[contains(text(),'quantity')]').extract()
or
response.css('script::contains(quantity)').extract()
And you will need a Regex to extract that JSON string
re.findall(r'(?<=dataLayer\.push\().*(?=\)\;)', your_script_tag_data, re.DOTALL)
javascript = response.xpath('//script[contains("quantity")]/text()').extract_first()
json_string = re.search( r'dataLayer\.push\((.+?)\);', javascript, re.DOTALL ).group(1)
data = json.loads(json_string)
print( "Quantity: {0}".format(data["product"]["quantity"]) )
In my experience, have no way to get quantity, category_path & etc by only Xpath, because they're in Json format. Xpath can get information in XML data.
I assume that you've already have xml data, use
python
data = yourXML.xpath('//script//text()')
Now data is a string that contain all information. Then, you need to get string in dataLayer.push and convert it to Json format. With Json, it' easy to get your information.
I have maybe a stupid question but how I can to download files from ftp server.
I use the route
.from("ftp:/test#localhost:21/?password=test") .to("file:/d:\\test")
I have the error : can not store null body. Why ? I read several examples Where is my error? Thanks
EDIT
I use the route :
.from("direct:xx")
.from("ftp://test#localhost:21/?password=test")
.to("file://d:\inbox");
And I have the error :
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot write null body to file: d:\inbox\xxxxxxx
at org.apache.camel.component.file.FileOperations.storeFile(FileOperations.java:237)
at org.apache.camel.component.file.GenericFileProducer.writeFile(GenericFileProducer.java:277)
at org.apache.camel.component.file.GenericFileProducer.processExchange(GenericFileProducer.java:165)
at org.apache.camel.component.file.GenericFileProducer.process(GenericFileProducer.java:79)
This should work.
.from("ftp://test#localhost:21/?password=test").to("file://d:\\test")
I am pretty sure about the from part. But the to part you might have to change a little bit(wrt '/') because I have not worked on windows
Add parameter 'allowNullBody=true' to your TO file endpoint
to("file://d:\test?allowNullBody=true")
If you go deep into source code as state in org.apache.camel.component.file.FileOperations.storeFile(FileOperations.java:237), you will see the related GenericFileOperationFailedException happens when
In Body of exchange is null
allowNullBody is set to false
By default, allowNullBody in File producer is 'false' as state in Camel File Component. You need to change it to 'true' to allow storage of empty files.
I am writing auto test scripts in QTP (UFT).
I have multiple columns in an external datasheet which could contain data or be blank. I was trying write some code, that if it was blank to click a submit button, if not blank then add in the fields. Please see code below:
If IsNull(DataTable("Available_Qualifications_1", dtLocalSheet)) = False then
Browser("Create Qualification Types").Page("Create Qualification Types").WebList("qavailable").Select DataTable("Available_Qualifications_1", dtLocalSheet)
Browser("Create Qualification Types").Page("Create Qualification Types").Link("Add Qualifications").Click
ElseIf IsNull(DataTable("Available_Qualifications_1", dtLocalSheet)) then
Browser("Create Qualification Types").Page("Create Qualification Types").WebButton("Submit").Click
End if
However, I receive the error below:
Cannot identify the specified item of the qavailable object. Confirm that the specified item is included in the object's item collection.
Line (16): "Browser("Create Qualification Types").Page("Create Qualification Types").WebList("qavailable").Select DataTable("Available_Qualifications_1", dtLocalSheet)".
What UFT is saying is that you're trying to set a value into the WebList which isn't one of the WebList's options.
Try outputing the value to see if UFT is correct, if it is then correct your test (by entering the correct values in the data table). If it's not correct you can try using the index by using the Select "#3" syntax (and report the problem to HP's support).
I am trying to implement multiple language support for my web project. I am new to it.
I am not able to get the resource file value by using ResourceManager.GetString() function. I am passing the name and current CuluralInfo. The resource file present in my App_GlobalResources are Sample.resx, Sample.en-us.resx, Sample.zh-cn.resx and Sample.ar-sa.resx. I am having a name field named "Heading1" and its value in all the resource files
My code is like
string Heading1= Resources.Global.ResourceManager.GetString(("Heading1", Thread.CurrentThread.CurrentCulture);
But it is always returning null value. Please help me to get the solution for this problem
Thanks
San
I found the problem
The code should be like
string Heading1= Resources.Sample.ResourceManager.GetString(name, culture_object);