httpwebreqest/httpwebresponse を使用していますが、一部のサイトで httpwebresponse が Cookie を認識しないという問題があります。これが response.Headers が返すものです。
Cookie1=1;domain=subdomain.host.com;path=/;Expires=Thu, 30-Oct-1980 16:00:00 GMT
Cookie2= ; HTTPOnly= ; domain=subdomain.host.com;path=/;Expires=Thu, 30-Oct-1980 16:00:00 GMT,
Cookie5= ; domain=.host.com;path=/;HTTPOnly= ;version=1
Cookie3=2; expires=Thu, 30-Oct-1980 16:00:00 GMT;domain=.host.com;path=/;HTTPOnly= ;version=1
Cookie4=3; domain=.host.com;path=/;version=
Raw (response.Headers からの Cookie はすべて 1 行の文字列です):
Cookie1=1;domain=subdomain.host.com;path=/;Expires=Thu, 30-Oct-1980 16:00:00 GMT,Cookie2= ; HTTPOnly= ; domain=subdomain.host.com;path=/;Expires=Thu, 30-Oct-1980 16:00:00 GMT,Cookie5= ; domain=.host.com;path=/;HTTPOnly= ;version=1,Cookie3=2; expires=Thu, 30-Oct-1980 16:00:00 GMT;domain=.host.com;path=/;HTTPOnly= ;version=1,Cookie4=3; domain=.host.com;path=/;version=
次の正規表現は完全に機能します。
(.*?)=(.*?);
しかし問題は、ドメインと有効期限もスクレイピングする必要があることですが、ドメインと「有効期限」が混在する場所に表示されます。すべての Cookie をスクレイピングしてドメインと有効期限フィールドを取得するにはどうすればよいですか? ありがとう!