im trying to scrape this page https://www.facebook.com/chefbudda/ (title, email and address)
i tried several classes for all these info, but none of them are working.
yield {
'title': response.css('title::text').extract(),
'email': response.xpath('.//*[contains(text(), "#")]').extract()[0],
'url': response.url
}
url and title are correctly scraped.
Any idea?
Thanks!
Related
Is there something I can do to prevent axios from renaming my FormData field name when it is an array.
For example:
I have an array of images I am posting using the field name of images. When I post this, I notice in the payload of my browser the field becomes multiple fields, i.e. it becomes images.0 and images.1.
In other words it looks like axios is renaming the field and making multiple fields with names like images.N.
Is there any way to avoid this renaming? On the server side I am using node with Nestjs and multer.
My Nestjs controller function expects a field name images but it throws an "unexpected field" error because axios renames the fields to images.0 and then images.1.
NestJS controller function that fails (note the field name):
#Post()
#UseGuards(AuthGuard('jwt'))
#UseInterceptors(FilesInterceptor('images', 30, { dest: './uploads' }))
create(
#Body() body: CreateAssetDto,
#User() user: RequestUser,
#UploadedFiles() files: Array<Express.Multer.File>,
) {
console.log(files, body, user.userId);
//return this.assetsService.create(body, user.userId);
}
NestJs controller function that works (note the use of the field name images.0):
#Post()
#UseGuards(AuthGuard('jwt'))
#UseInterceptors(FilesInterceptor('images.0', 30, { dest: './uploads' }))
create(
#Body() body: CreateAssetDto,
#User() user: RequestUser,
#UploadedFiles() files: Array<Express.Multer.File>,
) {
console.log(files, body, user.userId);
//return this.assetsService.create(body, user.userId);
}
To me, this code is the same, however in Chrome Dev Tools, the first request has the payload set:
But the second doesn't. Any ideas?
Based on an example from Axios Github page, the data property contains the payload
// Send a POST request
axios({
method: 'post',
url: '/user/12345',
data: {
firstName: 'Fred',
lastName: 'Flintstone'
}
});
So, in your second request, you should change body to data
I am trying to query my MongoDB based on a userID and spotify song's URI, which looks something like this: spotify:local:A%24AP+Rocky::Goldie:194. However, it doesn't seem to work. My queries look something like this.
app.patch('/api/songs/:spotifyId/:songUri', (req, res) => {
var id = req.params.spotifyId;
var uri = req.params.songUri;
Song.findOne({
userId: id,
uri
}).then((song) => {
song.update({$inc: {count:1}}, (e)=>{console.log(e)})
res.send(song);
}).catch((e) => {
res.status(400).send();
})
})
I tried querying using only the userID, which worked, and only the URI, which didn't work. I also created some fake data using a URI that doesn't have colons or percentage signs, which worked. So, I think that my query is not working because of the colons or something.
Does anyone know exactly why the query is not working, and also if there is a way to get my query working using the URI? Or will I have to query using different information?
In that example, it seems that you are specifying that the object's userId should match "id" but don't specify what key you want "uri" to match with (Presumably something like "songUri").
You have:
{
userId: id,
uri
}
And maybe it should be something more like:
{
userId: id,
songUri: uri
}
Finally if that doesn't work, maybe try passing in a string for the Uri (surrounding it with quotes) and then parsing it on the backend with JSON.parse()
I'm trying to get all photos from my facebook pefil but all i got is a empty array data or only the perfil photo, i think that with could be my passport facebook error but with the facebook api im geting empty array too,
i try this,
https://graph.facebook.com/USERID/photos?access_token=USERTOKEN
i dont know what i'm doing wrong, i tried with photo type uploaded and doesn't work too, i just wanna all perfil photos.
reponse:
{
"data": []
}
If you are still receiving an empty array after obtaining the user_photos permission, try adding type=uploaded (options are uploaded or tagged), e.g.: /me/photos?fields=images&type=uploaded&access_token=...) or in the JS SDK:
FB.api("/me/photos", { fields: "images", type: "uploaded" }, (resp) => { console.log(resp) });
(Note you can always pass "me" instead of a user ID to get info for the current user)
When we create our apps, we usually add our own routes.
So using the baucis.rest i added some custom routes like example:
var controller = baucis.rest( {
singular: 'User'
} );
controller.put('/myroute/:id', function(req,res,done){
//doing something
})
My app runs and using the swagger ui i can see the operations about users.
GET /Users/{id} description
PUT /Users/{id} description
......
I would like to add my "/myroute/:id' to the generated swagger api.
PUT /Users/myroute/{id} description
Does anyone know how to do about this?
As of v0.9.0 , you can modify the swagger definitions directly. It's purely cosmetic, only altering the swagger documentation, not any other functionality.
For example:
var controller = baucis.rest('User');
controller.swagger.apis.push({
'path': '/Users/myroute/{id}',
'description': 'Myroute custom description.',
'operations': [
{
'httpMethod': 'PUT',
'nickname': 'putSomethingCustom',
'responseClass': 'User',
'summary': 'Something custom.'
}
]
})
controller.swagger.models is also exposed.