

























python -m pip install requests -i https://pypi.tuna.tsinghua.edu.cn/simple
import requests from datetime import datetime import time API_URL="http://localhost:55548/GetBooksList" def get_books(count:int): try: params={"cnt":count} response=requests.get(API_URL,params=params) response.raise_for_status() books=response.json() print(f'{datetime.now()},retrieve {len(books)} books') return books except requests.exceptions.RequestException as ex: print(f'{datetime.now()},ex:{ex}') return None if __name__=='__main__': while True: books_list=get_books(10) if books_list: for a in books_list: print(a) time.sleep(5)
2026-05-12 14:03:53.072911,retrieve 10 books {'Id': 571, 'Author': 'Author_571', 'Abstract': 'Abstract_571', 'Name': 'Name_571', 'ISBN': 'ISBN_571', 'Title': 'Title_571', 'Topic': 'Topic_571', 'Comment': 'Comment_571', 'Content': 'Content_571', 'Summary': 'Summary_571'} {'Id': 572, 'Author': 'Author_572', 'Abstract': 'Abstract_572', 'Name': 'Name_572', 'ISBN': 'ISBN_572', 'Title': 'Title_572', 'Topic': 'Topic_572', 'Comment': 'Comment_572', 'Content': 'Content_572', 'Summary': 'Summary_572'} {'Id': 573, 'Author': 'Author_573', 'Abstract': 'Abstract_573', 'Name': 'Name_573', 'ISBN': 'ISBN_573', 'Title': 'Title_573', 'Topic': 'Topic_573', 'Comment': 'Comment_573', 'Content': 'Content_573', 'Summary': 'Summary_573'} {'Id': 574, 'Author': 'Author_574', 'Abstract': 'Abstract_574', 'Name': 'Name_574', 'ISBN': 'ISBN_574', 'Title': 'Title_574', 'Topic': 'Topic_574', 'Comment': 'Comment_574', 'Content': 'Content_574', 'Summary': 'Summary_574'} {'Id': 575, 'Author': 'Author_575', 'Abstract': 'Abstract_575', 'Name': 'Name_575', 'ISBN': 'ISBN_575', 'Title': 'Title_575', 'Topic': 'Topic_575', 'Comment': 'Comment_575', 'Content': 'Content_575', 'Summary': 'Summary_575'} {'Id': 576, 'Author': 'Author_576', 'Abstract': 'Abstract_576', 'Name': 'Name_576', 'ISBN': 'ISBN_576', 'Title': 'Title_576', 'Topic': 'Topic_576', 'Comment': 'Comment_576', 'Content': 'Content_576', 'Summary': 'Summary_576'} {'Id': 577, 'Author': 'Author_577', 'Abstract': 'Abstract_577', 'Name': 'Name_577', 'ISBN': 'ISBN_577', 'Title': 'Title_577', 'Topic': 'Topic_577', 'Comment': 'Comment_577', 'Content': 'Content_577', 'Summary': 'Summary_577'} {'Id': 578, 'Author': 'Author_578', 'Abstract': 'Abstract_578', 'Name': 'Name_578', 'ISBN': 'ISBN_578', 'Title': 'Title_578', 'Topic': 'Topic_578', 'Comment': 'Comment_578', 'Content': 'Content_578', 'Summary': 'Summary_578'} {'Id': 579, 'Author': 'Author_579', 'Abstract': 'Abstract_579', 'Name': 'Name_579', 'ISBN': 'ISBN_579', 'Title': 'Title_579', 'Topic': 'Topic_579', 'Comment': 'Comment_579', 'Content': 'Content_579', 'Summary': 'Summary_579'} {'Id': 580, 'Author': 'Author_580', 'Abstract': 'Abstract_580', 'Name': 'Name_580', 'ISBN': 'ISBN_580', 'Title': 'Title_580', 'Topic': 'Topic_580', 'Comment': 'Comment_580', 'Content': 'Content_580', 'Summary': 'Summary_580'} 2026-05-12 14:03:58.083683,retrieve 10 books {'Id': 581, 'Author': 'Author_581', 'Abstract': 'Abstract_581', 'Name': 'Name_581', 'ISBN': 'ISBN_581', 'Title': 'Title_581', 'Topic': 'Topic_581', 'Comment': 'Comment_581', 'Content': 'Content_581', 'Summary': 'Summary_581'} {'Id': 582, 'Author': 'Author_582', 'Abstract': 'Abstract_582', 'Name': 'Name_582', 'ISBN': 'ISBN_582', 'Title': 'Title_582', 'Topic': 'Topic_582', 'Comment': 'Comment_582', 'Content': 'Content_582', 'Summary': 'Summary_582'} {'Id': 583, 'Author': 'Author_583', 'Abstract': 'Abstract_583', 'Name': 'Name_583', 'ISBN': 'ISBN_583', 'Title': 'Title_583', 'Topic': 'Topic_583', 'Comment': 'Comment_583', 'Content': 'Content_583', 'Summary': 'Summary_583'} {'Id': 584, 'Author': 'Author_584', 'Abstract': 'Abstract_584', 'Name': 'Name_584', 'ISBN': 'ISBN_584', 'Title': 'Title_584', 'Topic': 'Topic_584', 'Comment': 'Comment_584', 'Content': 'Content_584', 'Summary': 'Summary_584'} {'Id': 585, 'Author': 'Author_585', 'Abstract': 'Abstract_585', 'Name': 'Name_585', 'ISBN': 'ISBN_585', 'Title': 'Title_585', 'Topic': 'Topic_585', 'Comment': 'Comment_585', 'Content': 'Content_585', 'Summary': 'Summary_585'} {'Id': 586, 'Author': 'Author_586', 'Abstract': 'Abstract_586', 'Name': 'Name_586', 'ISBN': 'ISBN_586', 'Title': 'Title_586', 'Topic': 'Topic_586', 'Comment': 'Comment_586', 'Content': 'Content_586', 'Summary': 'Summary_586'} {'Id': 587, 'Author': 'Author_587', 'Abstract': 'Abstract_587', 'Name': 'Name_587', 'ISBN': 'ISBN_587', 'Title': 'Title_587', 'Topic': 'Topic_587', 'Comment': 'Comment_587', 'Content': 'Content_587', 'Summary': 'Summary_587'} {'Id': 588, 'Author': 'Author_588', 'Abstract': 'Abstract_588', 'Name': 'Name_588', 'ISBN': 'ISBN_588', 'Title': 'Title_588', 'Topic': 'Topic_588', 'Comment': 'Comment_588', 'Content': 'Content_588', 'Summary': 'Summary_588'} {'Id': 589, 'Author': 'Author_589', 'Abstract': 'Abstract_589', 'Name': 'Name_589', 'ISBN': 'ISBN_589', 'Title': 'Title_589', 'Topic': 'Topic_589', 'Comment': 'Comment_589', 'Content': 'Content_589', 'Summary': 'Summary_589'} {'Id': 590, 'Author': 'Author_590', 'Abstract': 'Abstract_590', 'Name': 'Name_590', 'ISBN': 'ISBN_590', 'Title': 'Title_590', 'Topic': 'Topic_590', 'Comment': 'Comment_590', 'Content': 'Content_590', 'Summary': 'Summary_590'} 2026-05-12 14:04:03.097868,retrieve 10 books {'Id': 591, 'Author': 'Author_591', 'Abstract': 'Abstract_591', 'Name': 'Name_591', 'ISBN': 'ISBN_591', 'Title': 'Title_591', 'Topic': 'Topic_591', 'Comment': 'Comment_591', 'Content': 'Content_591', 'Summary': 'Summary_591'} {'Id': 592, 'Author': 'Author_592', 'Abstract': 'Abstract_592', 'Name': 'Name_592', 'ISBN': 'ISBN_592', 'Title': 'Title_592', 'Topic': 'Topic_592', 'Comment': 'Comment_592', 'Content': 'Content_592', 'Summary': 'Summary_592'} {'Id': 593, 'Author': 'Author_593', 'Abstract': 'Abstract_593', 'Name': 'Name_593', 'ISBN': 'ISBN_593', 'Title': 'Title_593', 'Topic': 'Topic_593', 'Comment': 'Comment_593', 'Content': 'Content_593', 'Summary': 'Summary_593'} {'Id': 594, 'Author': 'Author_594', 'Abstract': 'Abstract_594', 'Name': 'Name_594', 'ISBN': 'ISBN_594', 'Title': 'Title_594', 'Topic': 'Topic_594', 'Comment': 'Comment_594', 'Content': 'Content_594', 'Summary': 'Summary_594'} {'Id': 595, 'Author': 'Author_595', 'Abstract': 'Abstract_595', 'Name': 'Name_595', 'ISBN': 'ISBN_595', 'Title': 'Title_595', 'Topic': 'Topic_595', 'Comment': 'Comment_595', 'Content': 'Content_595', 'Summary': 'Summary_595'} {'Id': 596, 'Author': 'Author_596', 'Abstract': 'Abstract_596', 'Name': 'Name_596', 'ISBN': 'ISBN_596', 'Title': 'Title_596', 'Topic': 'Topic_596', 'Comment': 'Comment_596', 'Content': 'Content_596', 'Summary': 'Summary_596'} {'Id': 597, 'Author': 'Author_597', 'Abstract': 'Abstract_597', 'Name': 'Name_597', 'ISBN': 'ISBN_597', 'Title': 'Title_597', 'Topic': 'Topic_597', 'Comment': 'Comment_597', 'Content': 'Content_597', 'Summary': 'Summary_597'} {'Id': 598, 'Author': 'Author_598', 'Abstract': 'Abstract_598', 'Name': 'Name_598', 'ISBN': 'ISBN_598', 'Title': 'Title_598', 'Topic': 'Topic_598', 'Comment': 'Comment_598', 'Content': 'Content_598', 'Summary': 'Summary_598'} {'Id': 599, 'Author': 'Author_599', 'Abstract': 'Abstract_599', 'Name': 'Name_599', 'ISBN': 'ISBN_599', 'Title': 'Title_599', 'Topic': 'Topic_599', 'Comment': 'Comment_599', 'Content': 'Content_599', 'Summary': 'Summary_599'} {'Id': 600, 'Author': 'Author_600', 'Abstract': 'Abstract_600', 'Name': 'Name_600', 'ISBN': 'ISBN_600', 'Title': 'Title_600', 'Topic': 'Topic_600', 'Comment': 'Comment_600', 'Content': 'Content_600', 'Summary': 'Summary_600'} 2026-05-12 14:04:08.110344,retrieve 10 books {'Id': 601, 'Author': 'Author_601', 'Abstract': 'Abstract_601', 'Name': 'Name_601', 'ISBN': 'ISBN_601', 'Title': 'Title_601', 'Topic': 'Topic_601', 'Comment': 'Comment_601', 'Content': 'Content_601', 'Summary': 'Summary_601'} {'Id': 602, 'Author': 'Author_602', 'Abstract': 'Abstract_602', 'Name': 'Name_602', 'ISBN': 'ISBN_602', 'Title': 'Title_602', 'Topic': 'Topic_602', 'Comment': 'Comment_602', 'Content': 'Content_602', 'Summary': 'Summary_602'} {'Id': 603, 'Author': 'Author_603', 'Abstract': 'Abstract_603', 'Name': 'Name_603', 'ISBN': 'ISBN_603', 'Title': 'Title_603', 'Topic': 'Topic_603', 'Comment': 'Comment_603', 'Content': 'Content_603', 'Summary': 'Summary_603'} {'Id': 604, 'Author': 'Author_604', 'Abstract': 'Abstract_604', 'Name': 'Name_604', 'ISBN': 'ISBN_604', 'Title': 'Title_604', 'Topic': 'Topic_604', 'Comment': 'Comment_604', 'Content': 'Content_604', 'Summary': 'Summary_604'} {'Id': 605, 'Author': 'Author_605', 'Abstract': 'Abstract_605', 'Name': 'Name_605', 'ISBN': 'ISBN_605', 'Title': 'Title_605', 'Topic': 'Topic_605', 'Comment': 'Comment_605', 'Content': 'Content_605', 'Summary': 'Summary_605'} {'Id': 606, 'Author': 'Author_606', 'Abstract': 'Abstract_606', 'Name': 'Name_606', 'ISBN': 'ISBN_606', 'Title': 'Title_606', 'Topic': 'Topic_606', 'Comment': 'Comment_606', 'Content': 'Content_606', 'Summary': 'Summary_606'} {'Id': 607, 'Author': 'Author_607', 'Abstract': 'Abstract_607', 'Name': 'Name_607', 'ISBN': 'ISBN_607', 'Title': 'Title_607', 'Topic': 'Topic_607', 'Comment': 'Comment_607', 'Content': 'Content_607', 'Summary': 'Summary_607'} {'Id': 608, 'Author': 'Author_608', 'Abstract': 'Abstract_608', 'Name': 'Name_608', 'ISBN': 'ISBN_608', 'Title': 'Title_608', 'Topic': 'Topic_608', 'Comment': 'Comment_608', 'Content': 'Content_608', 'Summary': 'Summary_608'} {'Id': 609, 'Author': 'Author_609', 'Abstract': 'Abstract_609', 'Name': 'Name_609', 'ISBN': 'ISBN_609', 'Title': 'Title_609', 'Topic': 'Topic_609', 'Comment': 'Comment_609', 'Content': 'Content_609', 'Summary': 'Summary_609'} {'Id': 610, 'Author': 'Author_610', 'Abstract': 'Abstract_610', 'Name': 'Name_610', 'ISBN': 'ISBN_610', 'Title': 'Title_610', 'Topic': 'Topic_610', 'Comment': 'Comment_610', 'Content': 'Content_610', 'Summary': 'Summary_610'}
//WCF //D:\C\WcfService4\WcfService4\Web.config <?xml version="1.0"?> <configuration> <appSettings> <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> </appSettings> <system.web> <compilation debug="true" targetFramework="4.8" /> <httpRuntime targetFramework="4.8" maxRequestLength="2147483647"/> </system.web> <system.serviceModel> <services> <service name="WcfService4.BookService"> <endpoint address="" binding="webHttpBinding" bindingConfiguration="WebHttpBinding_IBookSerive" behaviorConfiguration="webBehavior_test" contract="WcfService4.IBookService"/> <host> <baseAddresses> <add baseAddress="http://localhost:8080"/> </baseAddresses> </host> </service> </services> <bindings> <webHttpBinding> <binding name="WebHttpBinding_IBookSerive" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> </binding> </webHttpBinding> </bindings> <behaviors> <endpointBehaviors> <behavior name="webBehavior_test"> <webHttp/> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior> <!-- To avoid disclosing metadata information, set the values below to false before deployment --> <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> <serviceDebug includeExceptionDetailInFaults="true"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> <rewrite> <rules> <rule name="WCF Without SVC" stopProcessing="true"> <match url="^(.*)$"/> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/> </conditions> <action type="Rewrite" url="BookService.svc/{R:1}"/> </rule> </rules> </rewrite> <directoryBrowse enabled="true"/> </system.webServer> </configuration> //D:\C\WcfService4\WcfService4\IBookService.cs using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; using System.Text; namespace WcfService4 { // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IBookService" in both code and config file together. [ServiceContract] public interface IBookService { [OperationContract] [WebGet(UriTemplate="GetBooksList?cnt={cnt}",RequestFormat =WebMessageFormat.Json, ResponseFormat =WebMessageFormat.Json)] List<Book> GetBooksList(int cnt); } [DataContract] public class Book { [DataMember(IsRequired = true,Order =1)] public long Id { get; set; } [DataMember(IsRequired = true, Order = 2)] public string Author { get; set; } [DataMember(IsRequired = true, Order = 3)] public string Abstract { get; set; } [DataMember(IsRequired = true, Order = 4)] public string Name { get; set; } [DataMember(IsRequired = true, Order = 5)] public string ISBN { get; set; } [DataMember(IsRequired = true, Order = 6)] public string Title { get; set; } [DataMember(IsRequired = true, Order = 7)] public string Topic { get; set; } [DataMember(IsRequired =true, Order = 8)] public string Comment { get; set; } [DataMember(IsRequired =true,Order = 9)] public string Content { get; set; } [DataMember(IsRequired =true,Order =10)] public string Summary { get; set; } } } //D:\C\WcfService4\WcfService4\BookService.svc.cs using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.Text; using System.Threading; namespace WcfService4 { // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "BookService" in code, svc and config file together. // NOTE: In order to launch WCF Test Client for testing this service, please select BookService.svc or BookService.svc.cs at the Solution Explorer and start debugging. public class BookService : IBookService { private static long idx = 0; private long GetIncrementIdx() { return Interlocked.Increment(ref idx); } public List<Book> GetBooksList(int cnt) { List<Book> bksList = new List<Book>(); for (int i = 0; i < cnt; i++) { long a = GetIncrementIdx(); bksList.Add(new Book() { Id = a, Name = $"Name_{a}", ISBN = $"ISBN_{a}", Comment = $"Comment_{a}", Content = $"Content_{a}", Summary = $"Summary_{a}", Author = $"Author_{a}", Abstract = $"Abstract_{a}", Title = $"Title_{a}", Topic = $"Topic_{a}" }); } return bksList; } } }
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。