Given a Wikipedia user/editor id and a timeframe, is there a way in Python to get details about all the contributions/edits made the user/editor? I want to fetch details like page edited, action taken, bytes added/deleted in case of revision, and comments (if any). Is this possible at all?
Many thanks!
Yes, pywikibot’s User class has a .contributions() method you can use to iterate over all contributions for a user.
It returns a generator that, for each edit, yields a tuple of (pywikibot.Page, oldid, pywikibot.Timestamp, comment). You don’t get the diff, but you can retrieve the page at this point (page.getOldVersion(oldid=…)) and do the diff from the point just before.
Simple code example:
from pywikibot import Site, User
user = User(Site(), "SanMelkote")
for page, oldid, ts, comment in user.contributions():
print(Page.title(), comment)
Related
I'm running a local server playing around with an API using Django. I have a model called 'Users' populated with a few objects, and am using DefaultRouter.
I want to know what the URL would be if I were to DELETE a specific object from this model. For example, if I wanted to GET a user with an ID of 1 in this model, the URL would be: "localhost:8000/Users/1/". What would the equivalent be to DELETE this user?
I found an explanation of this on the REST API website (below), however, I don't understand what any of the syntaxes means.
What is {prefix}, {url_path}, {lookup} and [.format]? If anyone could provide an example of what this might be using a localhost that would be really helpful.
Thanks
Let us take an example of an API (URL) to update book data with id (pk) being 10. It would look something like this:
URL: http://www.example.com/api/v1/book/10/
Method: PUT/PATCH
With some data associated.
If you want to delete you just need to change method to DELETE instead of put or patch.
Regarding your second question lets compare the url with the parameters.
prefix: http://www.example.com/api/v1/book
lookup: 10
format: It specifies what type of data do you expect when you hit the API. Generally it is considered to be json.
url_path: In general, every thing after look up except query string is considered to be url_path.
So I have this website where people can report some tracks. People can do so even tho they're not member of said website and if they're not members, the system will assign them a random "pseudo member number" (pmn from here on) in the style of "not_a_member_XXXX".
$query_claimed = "SELECT * FROM claims_archive WHERE t20pctID=:t20pctID AND member_name=:member_name AND member_email=:member_email AND (member_number=:member_number OR member_number LIKE '%not_a_member_%')";
$stmt = $con->prepare($query_claimed);
$stmt->bindParam(':t20pctID', $t20pctID);
$stmt->bindParam(':member_name', $member_name);
$stmt->bindParam(':member_number', $member_number);
$stmt->bindParam(':member_email', $member_email);
$stmt->execute();
In the testing period we have had some songs have been reported by the same person with a pseudo-number and some with a member number. My problem is that if I make a query with a pmn and the song exists with the same member name and e-mail but with another member number, the code will insert it instead of displaying a message in the style of "You have already claimed this song".
But if I do the query with the member number, then it will display the above message even if the record has it reported with a pmn.
I thought there was something wrong with my logic, but running the above query on phpMyAdmin, it does show the record if there is any matches. I have read about precedence, in case it applies here, and in case there's some operator order I should know about. What am I doing wrong?
Thanks in advance and I hope I made myself understood (English isn't my first or second language).
EDIT to add some info: although I haven't been able to identify a specific pattern for this issue, I have identified that it happens with this particular record.
Im somewhat new to JIRA (skill level novice)
Jira v 6.4.8
JIM v 7.0.12
I am attempting to import issues using the Issue->Import from CSV (bulk create tool)
I have a defined ticket CM-1 as a parent ticket. A generic CSV looks like this
Summary, Parent ID, Issue ID
CM-2, CM-1,
CM-3, CM-1,
CM-4, CM-1,
The first import works successfully and maps as children to CM-1
We attempt to re-import (to update the ~100 fields that changed overnight, not shown in this example for clarity)
Summary, Parent ID, Issue ID
CM-2, CM-1, CM-2
CM-3, CM-1, CM-3
CM-4, CM-1, CM-4
We encounter an issue where new subtasks are created, and nothing is updated.
I have also tried to map the Issue ID found when a I inspect the subtask tickets XML. It looks something like this
<item>
<title>[CM-2] CM2</title>
<link>
https://website.net/browse/CM-2
</link>
<project id="11902" key="CM">Change Management</project>
<description>CM-2 Description</description>
<environment/>
<key id="191147">CM-2</key>
<summary>CM-2</summary>
Specifically the ""
So that would look like
Summary, Parent ID, Issue ID
CM-2, CM-1, 191147
CM-3, CM-1, 191148
CM-4, CM-1, 191149
Once again we see new issues created and no updates performed. I've read the documentation, searched their 'Answer's' asked multiple questions, searched everywhere, but im not seeing any solutions. We literally need to update thousands of tickets, at least once a day - we don't have the manpower to perform this task any other way.
Criteria:
This needs to be able to be performed by an end user or a team lead, they will have access to the bulk import tool (Bulk create) from the Issues-Import issue From CSV link but will not have access to the administrator level external project imports.
I know this isn't an ideal long term solution, and would like to investigate a method to further automate this but we need a solution short term (this).
I appreciate any and all responses. We are importing from a very outdated instance of remedy that's going to remain in use for the next ~3+ years.
Thanks,
Jacob
First of all, if you want to update issues via CSV, you must include an 'Issue Key' column and, during import, map it to the issue key field (CM-1,CM-2 etc. are issue keys in your example). Otherwise every import will generate new issues in JIRA.
The 'Issue ID' and 'Parent ID' columns refer to internal IDs (not issue keys). For adding/updating sub-tasks, you need to figure out the ID of the parent (see below), and in the CSV, write the parent id in the 'parent ID' column, and leave the 'issue ID' value empty. This is explained in the 'Creating sub-tasks' section here.
Figuring out the id of an existing JIRA issue is somewhat tricky (unless you import them from the beginning with your own internal ID which has some sense). An easy way from the GUI is to right click the Edit button and choose 'open in new tab'. Then, the URL of the edit page will include the id (e.g. http://jira-srv/secure/EditIssue!default.jspa?id=91796).
If you need to automate it, you will have to resort to directly querying the database (unless someone else can offer you a better way... as far as i know the REST API does not expose it). See the discussion here if you want details.
I'm trying to scrape the price from the first ticket here page using this xpath:
'.//*[#class="price"]/text()'
This works in the developer's console, but not when I run it in the scrapy shell using response.xpath. I have also tried to following in the shell:
'.//*[#class="initial"]/div[#class="price"]/text()'
and
'//*[#id="tVB901769989"]/div[1]/div[4]' (although I don't think that the id property can be used in the shell like this).
Is there something wrong with the xpaths that I've used, or is there some thing different with the way the page works? Any help would be appreciated. Thanks!
this happens because you are checking at different requests, the page you see doesn't have the information you need inside that file, but it gets it dynamically, in this case from: www.vividseats.com/javascript/tickets.shtml?productionId=1771684
There you can check the prices on json format, I think this is for one item:
{
"s":"Section 111",
"r":"8-22",
"q":"4",
"p":"692.00",
"i":"VB782041491",
"d":"111",
"n":"Zone Seating. The seller is committing to procure these tickets for you upon receipt of your order. After you place your order and your order is confirmed, we guarantee that your tickets will be within the listed zone
or section listed or one comparable and that you will receive these tickets in time for the event or
your money back. Orders exceeding four tickets may be split up into different rows within the requested
zone or section.",
"f":"0",
"l":"Section 111",
"g":"0",
"e":"0",
"h":"07/21/15",
"t":"0",
"v":"",
"c":"84352",
"z":"1",
"rhdn":"0",
"ind":"0",
"sd":"0"
}
where p contains the price.
I'm trying to retrieve only top-level comments with a count or all comments (including replies) for a given post from the Facebook graph.
Has anyone got the Facebook graph comment filter or summary fields on comment graph calls to work? It says in the docs https://developers.facebook.com/docs/graphapi/guides/comments/ you can add a ?filter=stream and or ?summary=true to the graph url to include comment replies and or summary information (counts) in the collection of returned comments.
A hypothetical example is: for a public feed Facebook will tell you that a post has 100 comments and this number includes replies, when you actually retrieve the comments you may only get back 80 because the graph only returns top-level comments not comments and their replies.
Real example
graph.facebook.com/10151579052696276/comments/
gets all the first 25 comments from a post (using the object_id) but excludes replies. It only returns top level comments. This is a problem because the post comment count Facebook returns doesn't match the number of comments it returns. If you try and make comment pagination your screwed because its inconsistent.
To fix this i tried to add the filter stream and summary
graph.facebook.com/10151579052696276/comments/?filter=stream&summary=true
returns the exact same JSON.
I've tried including user access tokens (with all permissions) and an app token
try it yourself in the graph explorer https://developers.facebook.com/tools/explorer/
Any help would be much appreciated.
Your request Url is wrong
Delete "/" after "comments"
url should be like this;
graph.facebook.com/10151579052696276/comments?filter=stream&summary=true
Here's your answer:
>> For Comment Counts with their replies:
https://graph.facebook.com/80329313253_10153617216088254/comments?filter=stream&summary=true&access_token=yourtoken
>> For Comment Counts without their replies:
https://graph.facebook.com/80329313253_10153617216088254/comments?filter=toplevel&summary=true&access_token=yourtoken
Note: The above urls return a json object having two members (data array: which will show you the comment data, summary object: this will include a field showing total_counts)
It took long time for me to figure out that the summary is shown after all the comments array. Hope this answers your question.
I'm not sure if I understand the question entirely, but are you looking for a total number of Facebook comments for a given post? If so, this works:
https://graph.facebook.com/POST_ID/comments?summary=true&access_token=XXX
After all the comment id's, comment likes, etc there should be this summary:
summary: {
order: "chronological",
total_count: NUMBER
}
It returns the same json, because you request for a LIST of comments.
If you just want the summary, you have to avoid any pagination with the limit-parameter. try this:
graph.facebook.com/10151579052696276/comments/?filter=stream&summary=true&limit=0
in php i used this syntax:
$url="http://graph.facebook.com/?fields=og_object{comments.limit(0).summary(total_count)&10151579052696276";
$FB_Request = file_get_contents($url);