これは、低レベルのソケット通信を行う方法を学ぶのに非常に難しいステップでしたが、本当にこれを学びたいと思っています。壁に来て、適切な方法を見つけることができないようです.
すべてのデータを取得するにはどうすればよいですか? 複数のことを試しましたが、応答の一部しか取得できません。
私が今試しているURLは次のとおりです。
http://steamcommunity.com/market/search/render/?query=&start=0&count=100&search_descriptions=0&sort_column=price&sort_dir=asc&appid=730&category_730_ItemSet%5B%5D=any&category_730_ProPlayer%5B%5D=any&category_730_TournamentTeam%5B%5D=any&category_730_Weapon%5B%5D=any&category_730_Rarity%5B%5D=tag_Rarity_Ancient_Weapon
調査の結果、この方法を試しましたが、上記の完全な JSON ページを印刷できませんでした。何か間違っていますか?
sock.send(request)
response = ""
first = True
length = 0
while True:
partialResponse = sock.recv(65536)
if len(partialResponse) != 0:
#print("all %s" % partialResponse)
# Extract content length from the first chunk
if first:
startPosition = partialResponse.find("Content-Length")
if startPosition != -1:
endPosition = partialResponse.find("\r\n", startPosition+1)
length = int(partialResponse[startPosition:endPosition].split(" ")[1])
first = False
# add current chunk to entire content
response += partialResponse
# remove chunksize from chunck
startPosition = response.find("\n0000")
if startPosition != -1:
endPosition = response.find("\n", startPosition+1)
response = response[0:startPosition-1] + response[endPosition+1:]
if len(response[response.find("\r\n\r\n")+2:]) > length:
break
else:
break
print response